简体   繁体   English

IIS Express无法通过基本身份验证提供静态文件

[英]IIS Express Not Serving Static Files Over Basic Authentication

I have a ASP.NET WEB API 2 application which was configured to use Windows Integrated Authentication and was working without an issue. 我有一个ASP.NET WEB API 2应用程序,该应用程序配置为使用Windows集成身份验证,并且可以正常工作。

When I change the authentication mode to basic, none of the static files are served by IIS Express. 当我将身份验证模式更改为基本身份验证时,IIS Express不会提供任何静态文件。 Instead it returns 500. Rest of the files like aspx are getting served without an issue. 相反,它返回500。其余的文件(如aspx)可以毫无问题地得到处理。

Any ideas why this might be happening? 任何想法为什么会发生这种情况?

I'm using Visual Studio 2013, but also tried it on Visual Studio 2015 and got the same result. 我正在使用Visual Studio 2013,但也在Visual Studio 2015上进行了尝试,并获得了相同的结果。

PS: Static files are getting served fine when deployed on a full IIS instance. PS:将静态文件部署在完整的IIS实例上时可以很好地服务。

PS2: I've the following in my web.config: PS2:我的web.config中包含以下内容:

<staticContent>
  <remove fileExtension=".woff2" />
  <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
  <clientCache cacheControlMode="DisableCache" />
</staticContent>

UPDATE: If I remove the 更新:如果我删除

<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />

part, IIS Express serves all the static content except the .woff2 files, if I leave it in, it doesn't serve any static files. 部分,IIS Express提供除.woff2文件之外的所有静态内容,如果我将其保留,则它不提供任何静态文件。

Thanks in advance 提前致谢

After doing research, I figured out it was due to UAC. 经过研究,我发现这是由于UAC造成的。

Please refer to this for more information. 请参阅以获取更多信息。

I had the exact same issue when trying to load babylon js files, I found the issue seems to be that ISS doesn't like being 'side loaded' with additional mime types. 当尝试加载巴比伦js文件时,我遇到了完全相同的问题,我发现问题似乎是ISS不喜欢被“侧面加载”其他mime类型。

Now to fix this, you could mess with the UAC for your computer, or you can add those mime types to your application host file under 现在要解决此问题,您可以将计算机的UAC弄乱,或者可以将这些mime类型添加到您的应用程序主机文件下,

%userprofile%\\documents\\iisExpress\\config\\applicationhost.config

I added mine to the top of the pile of mime types already in there: 我将我的添加到已经存在的mime类型堆的顶部:

<staticContent lockAttributes="isDocFooterFileName">
        <mimeMap fileExtension=".json" mimeType="application/text" />
        <mimeMap fileExtension=".dds" mimeType="application/dds" />
        <mimeMap fileExtension=".tga" mimeType="application/tga" />
        <mimeMap fileExtension=".fx" mimeType="application/fx" />
        <mimeMap fileExtension=".babylon" mimeType="application/babylon" />
        <mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata" />
        <mimeMap fileExtension=".babylonbinarymeshdata" mimeType="application/babylonbinarymeshdata" />
        <mimeMap fileExtension=".cache" mimeType="text/cache-manifest" />
        <mimeMap fileExtension=".323" mimeType="text/h323" />
        .....

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

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