11

I have a web site running via IIS7 on Vista. The site is running on port 88, so http://localhost:88 should render the default /Home/Index view.

This works correctly, as do all other views.

However, one problem is resident. My script paths point to /Scripts/[FILE] and my CSS paths point to /Content/[FILE]. My assumption was that the /Content or /Scripts folder would always be at the root of the site as I have no intention to run this site in a virtual directory setting. Whenever the pages render, they have NO CSS or script! So everything looks wonky and the scripting obviously doesn't work, hence a lot of the views don't work either.

This is a very odd problem, one that I'm sure is a result of my lack of knowledge hosting things under IIS7. I'd appreciate any help anyone could offer. Thanks a lot!

brady gaster
  • 1,506
  • 1
  • 10
  • 15
  • Could you post the rendered HTML so that we can help you? – Brian Vallelunga Dec 09 '08 at 18:23
  • When I try to browse to http://localhost:88/Content/Site.css, I get an ASPX 404 error message. It seems the CSS extension is being processed by the ASPNET isapi filter (weird as all get-out!). – brady gaster Dec 09 '08 at 18:53

5 Answers5

12

I hope the continuation of this thread conveys a willingness to make sure this problem doesn't drive anyone off the cliff. There's a lot of documentation in various forums about solving this issue on Vista but I couldn't find any likewise articles for 2K8. As indicated in this forum post I was able to fix the issue on a Vista machine. Alas, a like execution failed to resolve the matter on 2K8.

I had verified that the StaticFileHandler had been included in the web.config as suggested in this blog post at apijunkie.com. Still, no luck.

Clarifying no luck, here - My server-side functionality was perfect. All MVC routes work like a champ. Just all CSS and JS rendering failed. When browser pointed directly at CSS or JS files resulting page was an ASP.NET 404 and not the traditional 404 error page.

So I went into the IIS7 Manager and into the Handler Mappings dialog. I added a new handler that specified the System.Web.StaticFileHandler type and gave it an extension of *.CSS. Then I repeated that for *.JS, *.PNG, and *.GIF files. When I refreshed the site in the browser, everything rendered perectly. The screen shots below demonstrate this process.

The Handler Mappings Window:

handler mappings
(source: windows.net)

Adding a new Managed Handler

alt text
(source: windows.net)

This resolved the problem, and now I have a perfectly functioning MVC app hosted in W2K. Time for a Guinness.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
brady gaster
  • 1,506
  • 1
  • 10
  • 15
7

From Control Panel, go to Turn Windows features on or off, then check Static Content in sub-sub-sub node of IIS.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Second Person Shooter
  • 14,188
  • 21
  • 90
  • 165
3

The problem was in the way I created the application. According to the forum thread located here, I needed to select the "Classic .NET AppPool" to fix my problem. Gotta love progress!

brady gaster
  • 1,506
  • 1
  • 10
  • 15
  • When I created the app pool, I left the default mode: `Integrated`... I just changed to `Classic` and seems to work. Thanks – Jaider Oct 05 '12 at 04:39
0

Turns out this isn't a fix on Windows 2008. Should anyone have any ideas on how to resolve this matter it'd be appreciated.

Detailed problem:

Windows 2K8 Server, IIS7. Have pipeline turned on and static file support installed. MVC works, but CSS doesn't render.

What the heck?

brady gaster
  • 1,506
  • 1
  • 10
  • 15
-2

The problem not lies precisely in the authorization/authentication but in the modules that now manages the IIS. Inside system.webServer you should have runAllManagedModulesForAllRequests set to false so you can display all images/css without problems with authentication.

In ASP.NET websites, the value of runAllManagedModulesForAllRequests previously had to be set to true to support routing. However, once IIS 7 has been updated with a Service Pack, the value of runAllManagedModulesForAllRequests can be set to false or omitted when working with ASP.NET routing.

Ref. http://www.iis.net/configreference/system.webserver/modules

P.S. Don't forget to add the following lines to the AppSettings section of my web.config file:

< add key="autoFormsAuthentication" value="false" />

< add key="enableSimpleMembership" value="false"/>

Ivan Paniagua
  • 312
  • 2
  • 10