I was writing a question asking why @Href isn’t recognizing the path correctly.
E.g.
@helper CSS(string cssFile, string media = "screen") {
<link href="@Href("~/content/stylesheets/" + @cssFile)" rel="stylesheet" type="text/css" media="@media" />
}
is throwing sereval js 404 error trying to found the resource in
- http:// localhost/content
- http:// localhost/dashboard/content
and never what I want:
- http:// localhost/MySite/content
So them I found the interesting part: @Url.Content instead of @Href works fine! Why!?
Therefore this is not the bigger problem, the issue is that in App_Code @Url doesn’t exist in the context. What I can use then.
MSDN is your friend. From WebPageRenderingBase.Href Method:
Whereas from UrlHelper.Content Method:
The tilde in your path makes it a virtual path, which apparently @Href() doesn’t understand.