IIS 7 Windows Server 2008 / CSS file not loading within aspx

耗尽温柔 提交于 2019-12-09 06:44:54

问题


I've found out several topics related to this issue yet I couldn't find an answer which worked for my problem, which is following: I moved my Asp.Net 4.0 site to a new server (IIS 7, Windows Server 2008). The server side is working fine but the CSS style sheet is not loading. When I use firebug, I see the following on the part where css should be loaded

404 - File or directory not found.

The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Despite this message,I can display the content of the css (in text) on the web (such as ../Styles/button.css ..etc)

I have tried some solutions such as staticFile handler mapping on IIS or adding ASP roles on server manager (through control panel).

Any help would be appreciated Kind regards


回答1:


The articles/topics that you have found is talking about the same thing as Uali's answer, which is correct, but it doesn't always solve everyone's problem. The problem is also not about your css per se.

Before proceeding, make sure that you have enabled Static Content as the other answer instructed.

Then do these steps in the IIS Manager window with your virtual directory selected.

  1. Open Handler Mappings.
  2. Click Add Managed Handler in the Actions Panel located in the right.
  3. In the request path field, type: *.css
  4. In the type textbox, enter: System.Web.StaticFileHandler
  5. In the name textbox, type in any descriptive name you want such as css fix.
  6. Click OK.

Update: I also forgot to say that you can do the same thing for .jpg, .png, .gif or any other file types if necessary.




回答2:


Please Make sure Your IIS 'Static Content' is enabled. Do to This follow these steps:

  1. Open Control Panel
  2. Click Programs
  3. Click Turn windows features on or off in Programs and Features.
  4. Open Internet Information services -> World Wide Web Service ->Common HTTP Features
  5. Make sure Static Content is checked, Mark checked if it is not.

Hopefully it will help you.




回答3:


The process of enabling Static Content on Windows 7 is different from that on Windows Server 2008.

To install the Static Content feature on Windows Server 2008 and Windows Server 2008 R2, follow these steps:

a. Open Server Manager, and then expand Roles. b. Right-click Web Server (IIS), and then click Add Role Services. c. Under Web Server, click to select the "Static Content" check box. d. Click Next to complete the installation.

Here is the complete step by step guide for both situation for reference. http://support.microsoft.com/kb/2196177



来源:https://stackoverflow.com/questions/12301893/iis-7-windows-server-2008-css-file-not-loading-within-aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!