Reputation: 2803
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?
Upvotes: 1
Views: 1805
Reputation: 1038710
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" />
Of course the same is true for all static resources such as javascript, images, ...
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 Net
tab of a javascript debugging tool such as FireBug where you would get 404 errors for the corresponding resource.
Upvotes: 2