How To Generate Absolute Urls With Https In MVC3
Apr 4, 2011
I am using MVC3 and am trying to serve content from https, the problem is that when I call Url.Content the files are still served from http using a relative url. I thought this problem was addressed in MVC3 but i can't seem to find any solution. Does anybody know if this issue is inherently solved in MVC3 and how to accomplish it or do I need to create my own helper methods to generate absolute Urls based on protocol?
View 2 Replies
Similar Messages:
Dec 2, 2010
My site was working fine before I starting working on incorporating URL redirection/rewriting. I have tried to preface all the URLs for graphic images and navigate URLs with a tilde and a slash ("~/"). However, now that I'm using rewriting on many of my pages, if the number of folders in the URL is 2 or less (such as MyDomain.com/Title/Author), it finds the graphics files without any problems, like before. When I view page source, I see that the HTML is calling for relative URLs that start with "../../", which is why it works for 2 or less folders in the URL. When there are 3 or more folders (such as MyDomain.com/Title/Author/Category), then it doesn't display the graphics files.
why I'm getting these relative URLs and so the files are not displaying correctly at times?
View 7 Replies
Feb 16, 2011
I need to force every request to https://www.mysite.com (always with https and www)
The site is hosted in GoDaddy and I need to do it via IIS7 URL Rewrite Module.
I've been able to do the HTTPS redirect with the following code:
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mysite.com$" />
</conditions>
<action type="Redirect" url="https://www.mysite.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
Test cases
http://mysite.com -> https://www.mysite.com OK
http://www.mysite.com -> https://www.mysite.com NOT WORKING
I guess the condition is not being satisfied when I enter www.mysite.com in the browser, so there's no redirect and the page serves as HTTP instead of HTTPS.
I think I just need to modify the condition pattern, but I have almost nothing regex knowledge and I need this asap.
View 1 Replies
Feb 28, 2010
I am using the NerdDinner project to experiment with MVC. http://nerddinnerbook.s3.amazonaws.com/Intro.htmI have put an image map on the front page and cannot work out how to generate the urls for it.
[Code]...
View 1 Replies
Oct 20, 2010
URLs are stored in a database, example:
home/page1
gallery/image1
info/IT/contact
home/page2
home/page3
gallery/image2
info/IT/map
and so on.
I would like to arrange the above urls into a tree fashion as shown below (each item will be a url link). The final output would be a simple HTML List (plus any sub list(s))
thus:
home gallery info
page1 image1 IT
page2 image2 contact
page3 map
Programming Language is C# , platform is asp.net
EDIT 1:
In the above example, we end up with Three Lists because in our example there is three main 'groups' eg: home, gallery, info.
View 3 Replies
Jun 7, 2010
I have a Table with a column containing Site Urls.
Eg. http:/Root1/Site1
http://Root1/Site2
http:/Root2/Site1
http:/Root3/Site3 ......... upto n number of sites.
I want to dynamically create a tree view from this Site Url data Such that Sub-sites are under there parent site.
View 7 Replies
Nov 16, 2010
i have a function that pulls URLs from various web resources. needless to say some are full valid URLS and some are relative as per the HTML of the page. below is my asp.net/ c# logic i derived for examining the URL and then generate a full usable URL from whats pulled from the site...
NOTE:
origianlurl is the full url of the first searched page, and relativeUrl is a url found within the searched page (it can be a full www.site.com or a /contactus.html)
private string ResolveRelativePaths(string relativeUrl, string originatingUrl)
{
if (relativeUrl.StartsWith("http") || relativeUrl.StartsWith("www"))
return relativeUrl;
if (relativeUrl.StartsWith("/"))
{
//get main url something.com
[code]...
View 1 Replies
Dec 16, 2010
Windows 7 Ultimate 64bit Visual Studio 2008 Team System Using C# SQL Server 2005 Express Management Studio (Service Pack 3) By using Visual Studio 2008,I opened Server Explorer and tried to modify Database connection,i wanted to use SQL Authentication,I entered User name and Passwored after pressing OK button,i got the following... Error message Failed to generate a user instance of SQL Server.Only an integerated connection can generate a user instance.The connection will be closed.
View 4 Replies
Feb 4, 2010
I am addressing page /MyPage.aspx. If I address it on my development server, it's absolute address is: [URL]If I address it on my operational server, it's abosolute address is: [URL] In Visual Basic, how do I programmatically get the server bit, that is http:// or http://localhost?
View 5 Replies
Jul 5, 2010
Is there some method in asp.net for getting an absolute url with cookieless session? UPDATE: I need create other new URL. It is not requested URL. I´m using Response.ApplyAppPathModifier for getting relative URL with cookie session.
View 2 Replies
Dec 14, 2010
Possible Duplicate: Absolute path & Relative Path
When to use absolute path, relative path and what is the difference between both?
View 2 Replies
Dec 14, 2011
I have developed a website and have always used relative positioning. I am now going to be writing a web application which will have a lot of text boxes / combo selections. My life would be a lot easier to use absolute positioning.
Would it be best to do it in relative or absolute for a web application. Basically I am taking a desktop app and rewriting it as an ASP.Net app.
View 8 Replies
Feb 7, 2011
I think the question says it all, but I'd like to know for sure.
View 1 Replies
Mar 27, 2011
I am currently in a dev only phase of development, and am using the VS built-in web server, configured for a fixed port number. I am using the following code, in my MembershipService class, to build an email body with a confirmation link, but obviously this must change when I deploy to our prod host.[URL]How can I build this URL to always reflect the host that the code is running on, e.g. when deployed to prod the URL should be http://our-live-domain.com/Account/..etc.MORE INFO: This URL will is included in an email to a new user busy registering an account, so I cannot use a relative URL.
View 3 Replies
Nov 24, 2010
I am wondering what the best method is. E.g.
<script type="text/javascript" src="<%= GetBaseURL() %>Scripts/jquery-1.4.1.min.js"></script>
renders
<script type="text/javascript" src="http://www.mywebsite.com/Scripts/jquery-1.4.1.min.js"></script>
Is there any danger or performance hit doing it this way?
View 3 Replies
Jun 21, 2010
I created a survey in vb.net where results are stored in an Excel file.Locally I can access and update the data of the file, but if I put online can not correctly access the excel file.How can I determine the absolute url of the file so, when a user submits the answers they can be inserted correctly in the excel file? Currently I use this to determine the location of the file:
Dim LocalizacaoFicheiro As String = String.Concat(Server.MapPath("."), "RespostasQuestionario.xlsx")
View 3 Replies
Jul 16, 2010
Im working on a project where i am implementing a friendly url system using the url rewite module in ii7.
This is all good and works great.
My only issue is that webresources.axd and Telerik.Web.UI.WebResource.axd both have relative paths. This causes lots of issues when the url is http://domain.com/some_page_name/
<script src="/WebResource.axd?d=mJUUfJUeVsvUq18HY14aGg2&t=634054669363345579" type="text/javascript"></script>
<script src="/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a1247b7d8-6b6c-419f-a45f-8ff264c90734%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.1.519.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3afcd44c12-f50d-4937-b05d-1aa46b5c5b3e%3a16e4e7cd%3aed16cbdc" type="text/javascript"></script>
Is there anyway I can assign an absolute url to these resources?
View 1 Replies
Nov 30, 2010
I want to put a textbox over an image, I can do that using absolute positioning but would rather not.
What is another way to accomplsih that?
View 5 Replies
Sep 9, 2010
I am really surprised that there is no native .NET method to get an absolute url from a relative url. I know this has been discussed many times, but never have come across a satisfactory method that handles this well. I think all I need left is to auto choose the protocol instead of hard coding it (http/https). Anything else I am missing (caveats, performance, etc)?
public static string GetAbsoluteUrl(string url)
{
//VALIDATE INPUT FOR ALREADY ABSOLUTE URL
if (url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
return url;
}
//GET PAGE REFERENCE FOR CONTEXT PROCESSING
Page page = HttpContext.Current.Handler as Page;
//RESOLVE PATH FOR APPLICATION BEFORE PROCESSING
if (url.StartsWith("~/"))
{
url = page.ResolveUrl(url);
}
//BUILD AND RETURN ABSOLUTE URL
return "http://" + page.Request.ServerVariables["SERVER_NAME"] + "/" + url.TrimStart('/');
}
View 6 Replies
Aug 24, 2010
have some kind of strange problem. I use Visual Studio 2008 Standard Edition, and whenever I use ~ in links (like PostBackUrl = "~/Admin/AddProduct.aspx"), ~ is translated into "C:DocumentAndSettingsUserDesktop" instead of my application root. Of course I dont have any project on Desktop. It happens in every project I run , even in project from pendrive which works properly on other computers.How can i solve this problem ? What and where should i change ?
View 8 Replies
Aug 17, 2010
In ASP.NET MVC 2, how can I get the absolute path to the Content folder from within a model?I'm trying to check for the existence of a file by calling IO.File.Exists. So, I need to convert the "~ContentisFile.png" relative path to an absolute path.I tried getting the application's directory path by calling My.Application.Info.DirectoryPath but that returned some temporary folder that doesn't contain the Content folder.
View 2 Replies
Mar 19, 2010
I have some controls within panel control.
In the deisgn time they all appear 0th position on panel.
if the textbox's top is defined as 250px, in the design time also it should appear exactly at 250Px position instead it is appering at the 0px of panel.
all controls are appearing at the top of panel frame.
this problem i didn't see in vs 2003 1.1 framework, usign vs 2008 it started.
But at runtime they do appear perfect what ever the position they were suppose to.
I know for sure i may have to do some settings on the VS ide.
View 2 Replies
Jan 20, 2010
I have the a test harness detailed below. This has two labels on the page that are set within the page_load which is hit every second due to the updatepanel and timer.
Label1 is set to a datetime value that is stored in the Cache. Label2 is set to the current datetime.
The cache is set with an absolute expiry of 5 seconds from now and there is an update callback on the cache to re-set the datetime and make it valid for another 5 seconds.
The problem I have is that I'm seeing the cache update every 20 seconds, not every 5 seconds like I would expect. If I set the time to 30 seconds then it updates every 40.
This appears to indicate that the cache will only expire every 20 seconds. Does anyone know of a way of reducing this time? If I just insert into the cache with an expiry of 5 seconds and no Callback then it works as I would expect and is removed every 5 seconds.
ASPX:
[Code]....
View 1 Replies
Jan 8, 2011
I'm just starting with using VWD and asp.net to create web sites.
I can't get a handle on how to use absolute positioning of asp server controls like the label, textbox, dropdown, etc. on a web form.
I've set the option in settings under CSS styling to change positioning to absolute when dragged from toolbox.
I've set the web form to use absolute positioning at every tag and property I can find.
When I first add the web form, I select absolute positioning. For each control I set absolute positioning and so on. I can see the tags in the source have the style property setup with position: absolute.
But the controls on the form will not move on the page to a absolute position.
Sometimes I can get a button or textbox to move, but not always.
I'm used to designing windows forms and this has been very frustrating.
View 1 Replies
Mar 18, 2011
I'm going to be deploying an app in the near future on an IIS7 server, and would like to use the per-application URL rewriting settings in web.config, but this is not an ASP.NET application, so I have no need for anything superfluous.
What is the absolute minimum I need in my web.config in order to run my application and use URL Rewriting?
View 1 Replies