Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an ASP.NET Web Forms site developed under Visual Studio 2012. There is a master page with navigation bar and links to CSS tables. Bot are specified using the application root operator "~"

<asp:PlaceHolder runat="server">
    <%: Styles.Render("~/Content/themes/base/css", "~/Content/css") %>
<li><a runat="server" href="~/Forms/SelectResults.aspx">Generate Table</a></li>
<li><a runat="server" href="~/BrowseDB.aspx">Browse DB</a></li>

When browsing the page http://localhost/Forms/SelectResults.aspx I see that the "~" is resolved differently for these cases:

<link href="/Content/site.css" rel="stylesheet" type="text/css" />
<li><a href="SelectResults.aspx">Generate Table</a></li>
<li><a href="../BrowseDB.aspx">Browse DB</a></li>

So path to CSS is absolute and path to other pages is relative. When running on localhost, all works fine. But after deploying my site to the server it has an address http://MyDomain/MySite/, so it is not located in the domain root. And because of absolute paths, no CSS files can be loaded! Navigation works fine, but all the styles are ruined.

Why doesn't "~" operator work in Styles.Render directive? Both code snippets was generated by the standard ASP.NET website template, I didn't modify anything.

Site was developed under Visual Studio 2012, .NET Framework 4.5. My server specifications are:

  • Windows 7 x64
  • IIS 7.5
  • Website Application Pool Framework 4.0
share|improve this question
up vote 1 down vote accepted

The problem was caused by our proxy server, who actually forwards http://MyDomain/MySite/ to http://InternalDomain:InternalPort/. And for that internal domain application root was actually a site root.

share|improve this answer
this kind of troubles are also caused by web.config files sometimes – happyhardik Aug 21 '12 at 12:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.