Im trying to convert an html template to ASP.Net MVC 4 project. Bbut i have run in an problem. Then opening the
localHost:11062/ site everything looks prefect. But if i try same address just calling the controller and action direct
localHost:11062/StartMenu/Index, which should be the same, but it's not. For me it looks like the css file isent loaded correct. But if it wasent the start site should not look different?
I suspect that you have hardcoded the url to some of your CSS files, just like this:
<link href="Content/Site.css" rel="stylesheet" type="text/css" />
instead of using an url helper:
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
You should never hardcode urls in an ASP.NET MVC application. Always use url helpers when dealing with urls.
Also if you are referencing some static resources (such as images) in your CSS file, don't forget that they should be relative to the location of the CSS file.
You might easily see this in the
There is currently no discussion for this recipe.
This recipe can be found in it's original form on Stack Over Flow.