Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are OPTIONS requests not arriving in my ASP.NET application?

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?

like image 864
Josef Pfleger Avatar asked Jul 11 '11 20:07

Josef Pfleger


1 Answers

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).

like image 50
driis Avatar answered Oct 31 '22 23:10

driis