asp.net-mvc-5.2razor-3

MVC5 relative path not working


I update my web application to MVC5. Since it requires Razor 3.0 then I updated it as well.

Suddenly relative paths are not resolved anymore, in _layout.cshtml a link like this:

<link rel="stylesheet" href="~/Content/main.min.css" />

is ok while rendering the home page http://example.com , but it's not referring the root when rendering a page like this http://example.com/level1/test

The link is resolved as: root/level1/Content/main.min.css


Solution

  • I found the reason, here's a link that explains it very well: URL rewrite issues with ASP.NET Razor 3