尽管我试图阻止静态文件,IIS仍然提供静态文件

时间:2015-09-14 15:09:06

标签: c# iis owin static-files

所以,我一直在研究利用Katana / Owin管道的项目。我正在尝试使用Owin安全地提供静态文件。现在,当我通过VS本地运行项目时,一切都运行得很好。

但是,当我将其部署到服务器(Windows Server 2008 R2,IIS 7)时,IIS已经决定在让任何脏托管处理程序管理其静态文件之前它会被诅咒。即使我删除了静态文件处理程序。即使我为特定路径添加了自己的处理程序。即使我已经告诉它为所有请求运行所有托管模块。并且由于传入的路径是虚拟路径,因此IIS当然会崩溃并死亡,并且会吐出500或404错误。我不完全确定是什么导致它在404上吐出500,但是只要请求深度超过1个目录,它就会超过404.(/Client/Content/Folder/static.html(404) vs /Client/Content/Folder/SubFolder/static.html(500))

我根本不确定从哪里开始。更糟糕的是,当我已经部署到我的本地IIS(没有从VS运行它,那就是。)它完美无缺。它尊重web.config,Owin中间件完美地处理静态请求,安全性到位。一切都是好的。当然,我在我的盒子上运行IIS 8 express,但我不相信那就是它。

1 个答案:

答案 0 :(得分:0)

I'm going to post my comment as an answer since the more I think about it, the more sure I am that it could be the issue.

Check that all necessary asp.net and IIS features have been installed correctly via Programs and Features - do a comparison between your dev and server environments. I've experienced essentially the same issues as yourself and this was usually the reason.

If this isn't the reason, check the IIS settings/Application pool settings make sure they are the on dev and production environments.