views:

98

answers:

2

I am editing a certain website which before used the port 80 (default) that was not required at the url (because it's default..)

But the port had (for technical reasons) to be changed, and now it has to be informed.

I can access the main page through ip:port\page like this:

1.2.3.4:81\page.aspx

Every link in the website is composed like this:

<asp:HyperLink runat="server" Text="random" NavigateUrl="~/fdr/whatever.aspx" />

And whenever I click on a link, the page doesn't load, but the URL is composed on the URL bar of the browser, then I simply add ":80" after the IP in the URL and it works.

Due to the existance of querystrings (in other words, for already having access to the URL) I before thought that '~' in the beginning of a URL in a link was saying "keep in the same website, just change to this webpage in this folder", but if the port vanishes, I assume now that the address is requested (probably to IIS) for the location of the current website.

I want to know then (instead of having to add the port to each link in my website) how do I set up whoever is requested by the ~ in the link to add the port somehow. How do I do that?

--[EDIT]--
Check this other question of mine for more info:

http://stackoverflow.com/questions/2454803/url-losing-port-number-in-every-page-load

+2  A: 

It points to the current root directory of the asp.net app (which may live in a subdirectory of the website). It allows links to be coded independent from whether the app lives in the root folder or not.

The Port / domain is never part of the game. Ports are assumed to be 80 -by your browser.

That said, what please is the technical reason to move an app off port 80? I know of not a single valid reason, sorry ;)

TomTom
If I knew exactly why it was changed, I'd say it. let's have technical reasons :(. It's not up to me to do this kind of things, then I'm just helping up. I'll test it trying to change to :80 before. Then about the question, you say there is no way to not inform the port in each link? it's a browser thing to assume it's 80, not an IIS thing to always send back as :80? ouch.. could you confirm on that? :(
MarceloRamires
There can be reasons to move off port 80... like when the default website (as installed as part of SBS2003) is set to use SSL, setting up a site under that is okay, but setting up SSRS under it is a huge PITA.
slugster
Slugster, it seems to me that you have some know-how in asp.net.. could you answer it and give me orientations to add the port in requests ? how should I do it ?
MarceloRamires
I dont think it CAn easily be done. That is the problem. ~ translates into a relative URl of the folder.... if the reuqest comes in at "/somepath/somefolder/somepage.aspx" and the browser gows to port 80 by default... that wont work... You need to put the complete domain there... non-standard... so whoever decided that can better pay fo rit.
TomTom
1. Security 2. Multiple apps with the same domain at the same IP (no host headers - don't ask me why, I've blocked it out on purpose) 3. Obfuscating the web address... blah blah blah
David Lively
+1  A: 

The ~ sign is known as the application root operator. You can read more about it here (MSDN) and to quote:

ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.

The following example shows the ~ operator used to specify a root-relative path for an image when using the Image server control In this example, the image file is read from the Images folder that is located directly under the root of the Web application, regardless of where in the Web site the page is located.

It's essentially a shortcut for the property System.Web.HttpRuntime.AppDomainAppVirtualPath.

Kev