1

Deployed MVC3 site to 2008 R2 Server, with IIS 7.5..

Basically CSS and Javascript libraries are not being loaded (e.g. In Firebug the CSS tab states that "There are no rules").

I've read elsewhere that the IIS_USR account needs to have permissions to see those files, so I've :

  • right clicked on the site
  • select edit permissions
  • select Security tab
  • added the "IUSR_[machinename]" users where [machiname] is the server name
  • granted read and execute privs

Also as answered in (Do MembershipProviders in ASP.net MVC affect stylesheet links?) I've added an autorization section for the content directory thus:

<location path="Content">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

Also.. As a matter of last resort I've amended the asp.net v4.0 app pool to use the LocalSystem identity rather than ApplicationPoolIdentity in case this was the issue, but alas not.

What have I missed?

5
  • How you are referring the css/js files? Commented Aug 29, 2012 at 12:01
  • use the firebug NET tab to see what all files are loading from which path and which are failing Commented Aug 29, 2012 at 12:14
  • Examples are <link href="@Url.Content("../Content/roleindex.css")" rel="stylesheet" type="text/css" /> and <link href="@Url.Content("../Content/Site.css")" rel="stylesheet" type="text/css" /> The NET tab doesn't seem to show anything... Commented Aug 29, 2012 at 12:21
  • @Shyju tell a lie, net tab lists the files but they all get 500 errors - Internal Server error. Paths look ok though.. Commented Aug 29, 2012 at 13:23
  • I am having the same problem with windows server 2012 and IIS 8 Commented Sep 3, 2013 at 21:49

1 Answer 1

1

I bet you've hardcoded the urls to those resources in your views, ilke this:

<script type="text/javascript" src="/scripts/foo.js"></script>

instead of using url helpers which is the correct way:

<script type="text/javascript" src="@Url.Content("~/scripts/foo.js")"></script>

Also get rid of the <location> tag from your web.config.

Remark: did you meant IIS 7.5?

Sign up to request clarification or add additional context in comments.

13 Comments

Hi Darin. I'm using url helpers... <link href="@Url.Content("../Content/Site.css")" rel="stylesheet" type="text/css" /> And also tried without the razor syntax to no avail ...<link href="../../Content/style.css" rel="stylesheet" type="text/css" /> I might as well get rid of the <location> tag as id did nothing...
You have to use the ~ with the Url.Content() helper.
Cheers @ZippyV, amended accordingly but still no luck. e.g. <link href="@Url.Content("~/Content/roleindex.css")" rel="stylesheet" type="text/css" />
In the Net tab of FireBug are those scripts served correctly? What status code does the server return when they are requested by the browser?
@Fetchezlavache - thank you for the response. I figured it out and answered it here: stackoverflow.com/questions/18642225/… Basically, the msi install was creating the wildcard mappings automatically, but that IIS metabase entry didn't play well with IIS8. I don't know if it works with IIS7.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.