简体   繁体   English

Windows 8 IIS无法在asp.net应用程序中加载样式表和图像

[英]Windows 8 IIS does not load stylesheets and images in asp.net app

I just installed Windows 8 on my computer and tried to load my ASP.net application. 我刚刚在计算机上安装Windows 8,并尝试加载ASP.net应用程序。 The page loads with no problems. 页面加载没有问题。 But none of the images or stylesheets that are located in the App_Themes directory load. 但是,不会加载App_Themes目录中的任何图像或样式表。 I do have a separate folder that has images in it and they do load. 我确实有一个单独的文件夹,里面有图像,并且它们确实在加载。 I think it is some security issue but I can't find out what it could be. 我认为这是一些安全问题,但我无法找到可能的问题。 If I deploy the site to my dev 2008 R2 box then the site loads correctly, but it doesn't load correctly on my Windows 8 box. 如果将站点部署到dev 2008 R2框中,则该站点可以正确加载,但是不能在Windows 8框中正确加载。

Some examples of my links are: 我的链接的一些示例是:

<link href="../App_Themes/Debug/style.css" type="text/css" rel="stylesheet" />

The above does not load. 以上未加载。

<img id="ctl00_imgCompanyLogo" title="Header Logo" src="../Images/EmailImage.aspx?ID=6C633997-065C-44AD-9839-B754005B7995" style="border-width:0px;height:50px;width:220px;margin-left: 10px" />

However, this one does. 但是,这一点确实如此。

Note: No errors are loaded on the page the files simply don't load. 注意:文件不会加载到页面上,不会加载任何错误。

Update: I should also note that this did work when I was using Windows 7 to write my code. 更新:我还应注意,当我使用Windows 7编写代码时,此方法确实起作用。

Update: I added a html page to my application and right clicked on that and that page didn't render. 更新:我在应用程序中添加了一个html页面,然后右键单击该页面,该页面未呈现。 However, if I create a new project, the pages render perfectly. 但是,如果我创建一个新项目,则页面将完美呈现。

Update2: I think I found the root of the issue but I don't know what to do about it. Update2:我认为我找到了问题的根源,但我不知道该怎么办。 If you create a new project on a Windows 8 machine then change the project so that it uses the virtual directory not IISExpress (use the Project Url) then none of the stylesheets load and the images won't load as well. 如果您在Windows 8计算机上创建一个新项目,然后更改该项目,使其使用虚拟目录而不是IISExpress(使用项目URL),则不会加载任何样式表,也不会加载图像。

I had a stupid moment. 我有一个愚蠢的时刻。 I didn't check the Static Content check box under the Common HTTP Features group of the IIS configuration. 我没有选中IIS配置的“公共HTTP功能”组下的“静态内容”复选框。

What worked for me: 对我有用的是:

在此处输入图片说明

Turning on all the features under Common HTTP Features. 打开“通用HTTP功能”下的所有功能。 I did not check this while installing Windows 8. 我在安装Windows 8时没有检查这一点。

Please refer this article: 请参考这篇文章:

http://gurustop.net/blog/2009/10/12/funny-problem-windows-7-iis-7-5-images-css-not-showing/ http://gurustop.net/blog/2009/10/12/funny-problem-windows-7-iis-7-5-images-css-not-showing/

Are you running the application through Visual Studio or have it setup in IIS? 您是通过Visual Studio运行应用程序还是在IIS中进行设置? If you are using Visual Studio to run it, by hitting F5, then you can try this in the web.config to allow anonymous users to access that folder: 如果使用Visual Studio运行它,请按F5键,然后可以在web.config中尝试此操作,以允许匿名用户访问该文件夹:

   <location path="App_Themes/Default/MyFile.css">
      <system.web>
         <authorization>
            <allow users="*"/>
         </authorization>
      </system.web>
   </location>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM