为什么w3wp.exe通过dotnetcore api路径查找web.config? [英] Why is w3wp.exe looking through my dotnetcore api path to find web.config?

查看:53
本文介绍了为什么w3wp.exe通过dotnetcore api路径查找web.config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序池中单独使用带有已部署dotnetcore 2.1或3.1 Web API的IIS 7时,我们发现在查看服务器上的Process Monitor时,w3wp.exe工作者记录了许多他们显然在寻找Web的错误.配置.他们检查了api路由中的每条路由.预期的行为是w3wp.exe(一个IIS工作程序)将移交"给客户端.对dotnetcore应用程序路由的请求,该请求将找到终结点,但相反,它似乎也在检查web.config.进程监视器显示w3wp.exe QueryOpen NAME NOT FOUND和PATH NOT FOUND错误.

我看了几篇文章,得出的结论是web.config继承存在问题,并且IIS或dotnetcore配置中必须有一些设置决定了检查每个API路由路径的行为,就好像它是虚拟的一样.可能包含新的web.config的目录文件夹系统.这样做的好处是,您可以在子应用程序中使用不同的web.config,但我们不希望这样做,也不想这些IIS工作人员在一天内浪费大量此类错误的日志.我们发现了一个非常简单的解决方案,IIS管理员可能会说"duh".但希望可以将某人保存在那里.

解决方案

我们在旧的blog.iis.net帖子中找到了有关web.config继承的答案(

  • 转到system.applicationHost =>站点=>虚拟目录默认值

  • 将allowSubDirConfig设置为False

  • 我们还发现Microsoft建议您使用此设置在IIS上托管dotnetcore应用程序

    跳过其他文件操作可以显着改善随机性非常大的网站的性能访问静态内容.

    https://docs.microsoft.com/zh-cn/previous-versions//dn529134(v=vs.85)?redirectedfrom=MSDN

    请记住,如果您使用此设置,则需要提出一种解决方案以分离使用或不使用该设置的应用程序.

    与MVC相关的问题: ASP.NET MVC安全性和IIS allowSubDirConfig配置

    Using IIS 7 with a deployed dotnetcore 2.1 or 3.1 web API alone in an application pool, we discovered while looking at Process Monitor on the server, the w3wp.exe workers were logging many errors where they were apparently looking for a web.config. They checked every route in the api's route. The expected behavior was that the w3wp.exe (an IIS worker) would "hand off" the request to the dotnetcore application's routing, which would find the endpoint, but instead, it appeared to be also checking for a web.config. The process monitor revealed w3wp.exe QueryOpen NAME NOT FOUND and PATH NOT FOUND errors.

    I looked at a few articles and concluded it was a problem with web.config inheritance, and there must be some setting in IIS or a dotnetcore configuration that was dictating the behavior of checking each API route path as if it were a virtual directory folder system that might contain a new web.config. The benefit would be that you could have a different web.config in a sub-application, but we didn't want that benefit and we didn't want these IIS workers blowing up the logs with thousands of these errors throughout the day. We found an insanely simple solution that an IIS admin might say "duh" but will hopefully save someone out there some time.

    解决方案

    We found the answer on an old blog.iis.net post about web.config inheritance (https://blogs.iis.net/steveschofield/control-web-config-inheritance-with-iis-7-asp-net-options). There is a configuration called allowsubdirconfig that directs the w3wp.exe worker to check subdirectories for a web.config file. Here's how you change it in IIS applicationhost.config that can be found through IIS Manager:

    1. Go to configuration editor

    2. Go to system.applicationHost => sites => virtual directory defaults

    3. Set allowSubDirConfig to False

    We also discovered that Microsoft recommends you use this setting for hosting dotnetcore applications on IIS

    Skipping the additional file operations can significantly improve performance of websites that have a very large set of randomly accessed static content.

    https://docs.microsoft.com/en-us/previous-versions//dn529134(v=vs.85)?redirectedfrom=MSDN

    Keep in mind, if you use this setting, you'll need to come up with a solution to separate applications that use or don't use the setting.

    Related issue with MVC: ASP.NET MVC security and IIS allowSubDirConfig configuration

    这篇关于为什么w3wp.exe通过dotnetcore api路径查找web.config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆