MVC + IIS7 = CSS Issue

前端 未结 5 1268
Happy的楠姐
Happy的楠姐 2021-02-08 05:14

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

5条回答
  •  星月不相逢
    2021-02-08 06:06

    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:


    (source: windows.net)

    Adding a new Managed Handler


    (source: windows.net)

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

提交回复
热议问题