子目录中的 Web.config 被忽略
我们在 IIS 站点中的应用程序下的虚拟目录的物理子目录中有一个 web.config。像这样的东西:
- 网站
- 应用程序
- Web.config
- 虚拟目录
- 子目录
- Web.config
- 子目录
- 应用程序
在 Web.config 中,我们将此配置放在 system.web 中:
<webServices>
<protocols>
<add name="HttpPost" />
<add name="HttpGet" />
</protocols>
</webServices>
我们在该子目录中为 ASMX 启用这两种协议。
它在一段时间内一切正常,然后就停止了,这些协议就停止工作了。我们重新启动 IIS,它又开始工作了。
为了解决这个问题,我们使用了一种解决方法,将该配置添加到应用程序 Web.config 中,然后它就可以正常工作了。但我们希望避免更改应用程序 Web.config,而是让子目录 Web.config 工作。
有什么想法为什么 ASP.Net 会在一段时间后停止考虑子目录 Web.config 吗?
我们在 Windows Server 2003、IIS 6、ASP.Net 2.0 上托管。
对 ASMX 的 HTTP POST 请求停止工作。我们收到的错误是 System.InvalidOperationException,并显示以下消息:
无法识别以“/blah”结尾的 URL 的请求格式。
堆栈跟踪是:
at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
We have a web.config in a physical subdirectory of a virtual directory that's under an application in an IIS site. Something like this:
- Site
- App
- Web.config
- Virtual Dir
- Subdir
- Web.config
- Subdir
- App
In the Web.config we put this configuration in system.web:
<webServices>
<protocols>
<add name="HttpPost" />
<add name="HttpGet" />
</protocols>
</webServices>
We enable both protocols for an ASMX in that subdirectory.
It all works fine for a while and after that it just stops and those protocols just stop working. We restart IIS and it starts working again.
To fix this, we have used a workaround to add that configuration to the application Web.config and then it just works fine. But we would like to avoid changing the application Web.config and instead make the subdirectory Web.config work.
Any ideas why ASP.Net would just stop considering the subdirectory Web.config after a while?
We're hosting on Windows Server 2003, IIS 6, ASP.Net 2.0.
HTTP POST requests to the ASMX stop working. The error we're getting is System.InvalidOperationException with this message:
Request format is unrecognized for URL unexpectedly ending in '/blah'.
The stack trace is:
at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
get 和 post 不太可能真的被间歇性地忽略。
你的 ASMX 在做什么?如果您正在分配而不是释放资源(例如与另一个服务或 WCF 对象的连接)或输入长时间运行的任务,则当这些资源耗尽时,IIS 可能会停止响应请求。这可以解释通过重新启动 IIS 可以解决问题。
您是否完全没有收到任何响应、错误 500 或其他什么情况?事件日志中有什么内容吗?
It's unlikely that get and post are really being ignored intermittently.
What is your ASMX doing? If you're allocating and not freeing a resource - like a connection to another service or WCF object - or entering a long-running task, IIS can stop responding to requests when those resources are exhausted. That would explain with restarting IIS fixes the problem.
Are you getting no response at all, an error 500, or what? Anything in the event log?