简体   繁体   中英

MVC3 Site scripts and CSS not loading

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

Basically CSS and Javascript libraries are not being loaded (eg 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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM