Remember that a web "site" is still an application, it's just the application at the root of the site.
When you develop in Visual Studio, as you have found, you usually work in a virtual directory. There is absolutely nothing inherently wrong with this method. I develop my web site in a virtual directory but it's hosted at the root of a web URL (
www.geekdork.com). The key is what you use for your URLs.
In .net you can build a URL in a server control like this: "~/myresource" When .net constructs the control, it replaces the ~ with the full path of the virtual directory (web application). Therefore, if you are developing here:
//localhost/subdir/subdir/subdir/subdir/mywebsite
you can make a link like this:
~/mypage.aspx
and when the page is rendered, the actual link in the href will be this:
/subdir/subdir/subdir/subdir/mywebsite/mypage.aspx
This applies to anything that uses a URL:
Links:
<asp:hyperlink runat="server" href="~/mypage.aspx" />
User controls registration directives:
<%@ Register tagprefix="tagprefix" Tagname="tagname" Src="~/myusercontrol.ascx" %>
So on and so forth. This will allow you to use root relative references without the need to write in the determination of whether you are running in a virtual directory or not.
If you want to use this functionality programmatically, there is a method on the page class for just this purpose: Page.ResolveUrl(). Just pass it the root relative URL with the ~ in it and it will give you back the complete URL with the applicable application path.
Peter
-------------------------
Work smarter, not harder