Problems with StaticFileModule in Web.config. Can't load styles, images on pages.

Topics: Installing Orchard, Troubleshooting
Aug 21, 2011 at 9:20 AM
Edited Aug 21, 2011 at 9:31 AM

I've just set up a Shared Hosting on IIS7 (managed with WebsitePanel), copied the files just like in the instructions. All is well, installation went successfully, however, throughout the entire process, I've been viewing non-styled pages with pure HTML, with no CSS or images loaded.

When I looked at the URL of the unloaded images or styles, I got a 500 page:

 


 

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

 


 

I was able to browse the directories right until the one containing the resources which couldn't be loaded. They all contained practically the same Web.config file, which determined the handlers for resources.

 

  <system.web>
    <httpHandlers>
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <add path="*" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers accessPolicy="Script,Read">
      <!--
      iis7 - for any request to a file exists on disk, return it via native http module.
      accessPolicy 'Script' is to allow for a managed 404 page.
      -->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
    </handlers>
  </system.webServer>

I decided to delete the element from <handlers> (for iis7). It worked. I was able to access the resources properly, but I didn't have to do that when running from WebMatrix, so then I reverted the config. So it definitely has something to do with StaticFileModule. I want to fix this problem server-wide, can anybody please point me to what I should do?

Coordinator
Aug 22, 2011 at 7:27 PM

Can you give more details about the error?

Aug 23, 2011 at 2:03 PM

It was me who wrote the question (had a cookie from another account, didn't notice).

It isn't quite an Orchard issue, I just thought that someone else might have encountered this problem with other hosting services.

Anyway, I played with the whole setup for a while. I talked with both the hosting support staff who advised that I re-create the website, which I did. I never actually changed anything, but the second time it worked. Can't explain it, however here's what the folks at ServerFault wrote:

http://serverfault.com/questions/303486/shared-hosting-on-iis7-not-able-to-access-resources-with-staticfilemodule-hand/303610#303610

Unfortunately I haven't had the chance to actually test the solution. I turned off the customErrors, but was still getting a simple 500 error page. If anyone else stumbles upon this problem, I hope this helps.

Thank you for your attention.

Coordinator
Aug 23, 2011 at 6:36 PM

Yeah, I've actually seen that happen before, with a similar resolution. I'm still quite puzzled by it.

Sep 17, 2011 at 9:54 PM

If you're using Arvixe hosting, then make sure you uncheck "Enable Parent Paths" for the website. 

I fought this for 2 hours...