为什么 OPTIONS 请求未到达我的 ASP.NET 应用程序?

发布于 2024-11-19 07:14:24 字数 1117 浏览 7 评论 0原文

我似乎无法在 IIS6 托管的 ASP.NET 应用程序中接收 HTTP OPTIONS 请求。我正在我的 Global.asaxApplication_BeginRequest 方法中使用调试断点(和文件日志)对其进行测试。断点永远不会被命中,客户端会收到 HTTP 403 Forbidden,我假设直接来自 IIS6(GETs 和 POSTs 工作正常)。

我在 web.config 中尝试了几件事,包括将以下行添加到 部分。

<add name="OptionsHandler" verb="OPTIONS" path="*" type="System.Web.DefaultHttpHandler"/>

我还使用了 设置以及 allowUnlisted="true"<添加动词=“OPTIONS”允许=“true”/>

另外,我没有使用 URLScan 或任何其他可能拦截调用的工具。如果您对 IISLogs 感兴趣:

2011-07-11 20:26:05 W3SVC1215124377 127.0.0.1 OPTIONS /test.aspx - 80 - 127.0.0.1 Mozilla/5.0+(Windows+NT+5.2;+rv:5.0)+Gecko/20100101+Firefox/5.0 403 1 0

有没有办法在 ASP.NET 应用程序中接收 OPTIONS 请求?

I can't seem to receive HTTP OPTIONS requests in my IIS6 hosted ASP.NET application. I'm testing it using a debug breakpoint (and file-log) in my Global.asax's Application_BeginRequest method. The breakpoint is never hit and the client gets a HTTP 403 Forbidden, I'm assuming from IIS6 directly (GETs and POSTs work fine btw).

I've tried several things in the web.config, including adding the following line to either and both the <system.webServer><handlers> and <system.web><httpHandlers> sections.

<add name="OptionsHandler" verb="OPTIONS" path="*" type="System.Web.DefaultHttpHandler"/>

I've also played with the <system.webServer><security><requestFiltering><verbs> settings and allowUnlisted="true" and <add verb="OPTIONS" allowed="true"/>.

Also, I'm not using URLScan or any other tools that might intercept the calls. In case you're interested in IISLogs:

2011-07-11 20:26:05 W3SVC1215124377 127.0.0.1 OPTIONS /test.aspx - 80 - 127.0.0.1 Mozilla/5.0+(Windows+NT+5.2;+rv:5.0)+Gecko/20100101+Firefox/5.0 403 1 0

Is there a way to receive OPTIONS request in an ASP.NET Application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶茶白久 2024-11-26 07:14:24

对于 IIS6,您必须在管理控制台中显式启用 OPTIONS 谓词,并且还需要将其映射为由 ASP .NET 处理。只有这样,您才能够在 中注册您的处理程序并让 ASP .NET 处理请求。

(请注意, 设置仅适用于 IIS7)。

For IIS6, you will have to enable the OPTIONS verb explicitly in the management console, and you will also need to map it to be handlded by ASP .NET. Only then, you will be able to register your handler in <system.web> and get the request processed by ASP .NET.

(Note, <system.webServer> settings only applies to IIS7).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文