Reputation: 31313
I am having trouble getting my local II7 to load stylesheets when running a default 'File/New' MVC3 website. When I run the site using Visual Studio everything works great. I created an IIS7 website pointed to the root folder of the MVC website. The site comes up, but no stylesheets load. My app pool is set for .NET 4 and Integrated mode.
The same issue was described in this topic, but the fix didn't help me (I already have the 'serve static content' setting checked).
ASP.Net MVC & Local IIS Issue Loading Stylesheets
Any direction is appreciated!
Upvotes: 9
Views: 8833
Reputation: 21
Another thing to check is that Static Content is enabled in Windows Features - this catches me out every time. In Windows 7:
Upvotes: 2
Reputation: 56859
I had this problem too, and none of the solutions here (or anywhere else that I could find) helped.
It turned out that my CSS files were downloaded from an external source in zip format. The files were copied and pasted from the zip file to my IIS directory using Windows Explorer. If you unzip the file first before doing the copy operation, then it won't mess up the permissions and you will be able to view them in IIS.
Upvotes: 1
Reputation: 31313
This was solved by enabling Anonymous Authentication in IIS, then right-clicking that node and choosing Edit and choosing Application Pool Identity. Everything loads correctly now. With fiddler I noticed I was getting 401 errors on the stylesheets/js files, so I knew I had a security issue.
Upvotes: 13
Reputation: 2997
In your layout page have the style sheet like:
<link href="@Url.Content("~/folder/style.css")" type="text/css" rel="stylesheet" />
This should help by making it relative to your applications root the @Url(Content("~/ part.
Upvotes: 4
Reputation: 26690
As @Mike said, I am almost willing to bet that the problem is that the path to the CSS file is different when you run local than when you run on the server.
Where are your CSS files located at?
For example, if your root IIS folder is c:\inetpub\wwwroot...are your CSS files under
?
Upvotes: 1