Can I configure ASMX to respond to an HTTP 1.1 OPTIONS request?

It seems that ASMX implicitly does not allow the verb OPTIONS. I am posting this question because I am using jQuery AJAX calls with POST, which first requests the server for available options before releasing the POST ** verb.

By default, Web.config matches all verbs to legacy ASMX, as shown in this partial configuration example, so everything should be properly routed:

<system.webServer>
    <requestFiltering>
        <verbs>
          <add verb="OPTIONS" allowed="true"/>
          <add verb="GET" allowed="true"/>
          <add verb="POST" allowed="true"/>
        </verbs>
    </requestFiltering>

<handlers>
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
       type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

However, the HTTP response is always 405 for the OPTIONS request. For example, the following query is provided:

OPTIONS http://localhost:35920/MarkupTransfomer.asmx HTTP/1.1
Host: localhost:35920
Access-Control-Request-Method: POST

and always leads to:

HTTP/1.1 405 Method Not Allowed
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727

The jQuery AJAX call looks like this: recommendation for a recent Encosia post for working with ASMX:

    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "http://localhost:35920/MarkupTransfomer.asmx",
        data: "{'hi'}",
        dataType: "json"
    });

** Note. I do not want to switch the client to using GET instead of POST.

:
ASP.NET, ASMX ?

,

  • jQuery.ajax(..) OPTIONS POST?

  • , ASMX, , :

    • System.Web.IHttpHandler, web.config handlers verbs=OPTIONS path=*.asmx ASMX . .
    • WCF. , ASMX .

, , , ( ).

# 1

, - . -, . , , , ! , ASMX HTTP. , HTTP- . .

+5
1

, ASMX - OPTIONS, AJAX. OPTIONS? OPTIONS?

, ASP.NET, OPTIONS. web.config, ASP.NET ASMX.

<add path="*" verb="*" type="System.Web.HttpMethodNotAllowedHandler" validate="True" />

405, .

-1

All Articles