简体   繁体   中英

CSS files not loading in IIS8, but loads in Visual Studio 2015

Strangest problem. I have an ASP.NET website (webforms) that works fine on VS2015, but all of the sudden, once I upload the files to IIS8 and try to view the site in the browser, none of the bundled CSS style sheets will load. Directly typing in the style sheet into the browser loads it fine. All javascript bundles also load and all pages and all references EXCEPT CSS. I've been fighting this for a day now and this is baffling (it WAS working on IIS8 - so it's not a config problem there - other sites have no problems either). It's not a security problem, either - IUSR has full access to the Content folder. Nothing on IIS was changed before this happened (except some windows server updates - could there be a bug?). I tried putting in a web.config file into the ~/Content folder to grant full access. No luck there. I've cleared the cache in FF,Chrome and IE thinking there was a cache issue - no luck. I've looked at the download (from the web developer console on FireFox) and all the files are downloading EXCEPT CSS!?!? My guess is that the CSS "bundling" feature is somehow not working (though the file hasn't been changed and was working fine on IIS).

  <?xml version="1.0" encoding="utf-8" ?>
    <bundles version="1.0">
      <styleBundle path="~/Content/css">
       <include path="~/Content/bootstrap.min.css" />
        <include path="~/Content/bootstrap-theme.min.css"/>
        <include path="~/Scripts/FooTable-2/css/footable.core.min.css" />
        <include path="~/Scripts/FooTable-2/css/footable.custom.css" />
        <include path="~/Scripts/gentleSelect/GS.css" />
        <include path="~/Content/Site.css" />
        <include path="~/Content/css/select2.min.css" />
        <include path="~/Content/select2-bootstrap.css" />  
      </styleBundle>
    </bundles>

The other suspect is that I updated bootstrap from Nuget (a minor version update) and, perhaps this corrupted the bundling. Not sure what happened, but it could take days of trial and error to determine this. Hoping someone else has had this problem (and a solution).

I figured out what was wrong. There was a folder called "css" in the "Content" folder. I moved the css files out of that folder and deleted it (that is, I deleted the css folder). So the bundle config looks like so:

<?xml version="1.0" encoding="utf-8" ?>
<bundles version="1.0">
  <styleBundle path="~/Content/css">
   <include path="~/Content/bootstrap.min.css" />
    <include path="~/Content/bootstrap-theme.min.css"/>
    <include path="~/Scripts/FooTable-2/css/footable.core.min.css" />
    <include path="~/Scripts/FooTable-2/css/footable.custom.css" />
    <include path="~/Scripts/gentleSelect/GS.css" />
    <include path="~/Content/Site.css" />
    <include path="~/Content/select2.min.css" />
    <include path="~/Content/select2-bootstrap.css" />  
  </styleBundle>
</bundles>

IIS gets confused if the styleBundle "path" actually has a folder with the same name - the last part of this "path" should not actually exist in the file structure. ASP.NET MVC framework 4.5 CSS bundles does not work on the hosting

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