However, in Web Pages Razor V2, the tilde notation in URLs maps to the rewritten URLs when the IIS URL rewriting module is enabled. For example, when the requests under content.asp.net are rewritten to the URL under asp.net/content/, the href attribute in <A href="~/book/"/> is resolved to /content/book/. In Web Pages Razor V3, the same href attribute is translated into /book/, which is the original URL in the browser.
protected void Application_BeginRequest(object sender, EventArgs e)
Context.Items["IIS_WasUrlRewritten"] = false;
Note The change of the IIS_WasUrlRewritten context affects the tilde notation not only in the HTML elements, but also in the MVC helper methods. For example, if it is set to false, the tilde notation in Url.Content and Html.ActionLink returns the rewritten URLs.
Article ID: 2905164 - Last Review: 31 Dec 2013 - Revision: 1