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

1 Answer 1


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.

  • this kind of troubles are also caused by web.config files sometimes Aug 21, 2012 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .