Request format is unrecognized for URL unexpectedly ending in

This is not a question – posting it here for reference:

When consuming a WebService, I got the following error:

Request format is unrecognized for URL unexpectedly ending in /myMethodName


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Found a solution on this website

All you need is to add the following to your web.config

        <add name="HttpGet"/>
        <add name="HttpPost"/>

More info from Microsoft

Method 2

Despite 90% of all the information I found (while trying to find a solution to this error) telling me to add the HttpGet and HttpPost to the configuration, that did not work for me… and didn’t make sense to me anyway.

My application is running on lots of servers (30+) and I’ve never had to add this configuration for any of them. Either the version of the application running under .NET 2.0 or .NET 4.0.

The solution for me was to re-register ASP.NET against IIS.

I used the following command line to achieve this…

C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet_regiis.exe -i

Method 3

Make sure you’re using right method: Post/Get, right content type and right parameters (data).

    type: "POST",
    url: "/ajax.asmx/GetNews",
    data: "{Lang:'tr'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) { generateNews(msg); }

Method 4


Case 2 – where the same issue can arrise) in my case the problem was due to the following line:

    <remove name="Documentation"/>

It works well in server as calls are made directly to the webservice function – however will fail if you run the service directly from .Net in the debug environment and want to test running the function manually.

Method 5

For the record I was getting this error when I moved an old app from one server to another. I added the <add name="HttpGet"/> <add name="HttpPost"/> elements to the web.config, which changed the error to:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at BitMeter2.DataBuffer.incrementCurrent(Int64 val)
   at BitMeter2.DataBuffer.WindOn(Int64 count, Int64 amount)
   at BitMeter2.DataHistory.windOnBuffer(DataBuffer buffer, Int64 totalAmount, Int32 increments)
   at BitMeter2.DataHistory.NewData(Int64 downloadValue, Int64 uploadValue)
   at BitMeter2.frmMain.tickProcessing(Boolean fromTimerEvent)

In order to fix this error I had to add the ScriptHandlerFactory lines to web.config:

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

Why it worked without these lines on one web server and not the other I don’t know.

Method 6

In my case the error happened when i move from my local PC Windows 10 to a dedicated server with Windows 2012.
The solution for was to add to the web.config the following lines

               <add name="Documentation"/>

Method 7

I use following line of code to fix this problem. Write the following code in web.config file

       <jsonSerialization maxJsonLength="50000000"/>

Method 8

I did not have the issue when developing in localhost. However, once I published to a web server, the webservice was returning an empty (blank) result and I was seeing the error in my logs.

I fixed it by setting my ajax contentType to :

"application/json; charset=utf-8"

and using :


on the object I was posting.

var postData = {data: myData};
                type: "POST",
                url: "../MyService.asmx/MyMethod",
                data: JSON.stringify(postData), 
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                dataType: "json"

Method 9

I also got this error with apache mod-mono. It looks like the documentation page for webservice is not implemented yet in linux. But the webservice is working despite this error. You should see it by adding ?WSDL at the end of url, i.e http://localhost/WebService1.asmx?WSDL

Method 10

In html you have to enclose the call in a a form with a GET with something like

<a href="/service/servicename.asmx/FunctionName/parameter=SomeValue" rel="nofollow noreferrer noopener">label</a>

You can also use a POST with the action being the location of the web service and input the parameter via an input tag.

There are also SOAP and proxy classes.

Method 11

In my case i had an overload of function that was causing this Exception, once i changed the name of my second function it ran ok, guess web server doesnot support function overloading

Method 12

a WebMethod which requires a ContextKey,

public string[] GetValues(string prefixText, int count, string contextKey)

when this key is not set, got the exception.

Fixing it by assigning AutoCompleteExtender’s key.

ac.ContextKey = "myKey";

Method 13

In our case the problem was caused by the web service being called using the OPTIONS request method (instead of GET or POST).

We still don’t know why the problem suddenly appeared. The web service had been running for 5 years perfectly well over both HTTP and HTTPS. We are the only ones that consume the web service and it is always using POST.

Recently we decided to make the site that host the web service SSL only. We added rewrite rules to the Web.config to convert anything HTTP into HTTPS, deployed, and immediately started getting, on top of the regular GET and POST requests, OPTIONS requests. The OPTIONS requests caused the error discussed on this post.

The rest of the application worked perfectly well. But we kept getting hundreds of error reports due to this problem.

There are several posts (e.g. this one) discussing how to handle the OPTIONS method. We went for handling the OPTIONS request directly in the Global.asax. This made the problem dissapear.

    protected void Application_BeginRequest(object sender, EventArgs e)
        var req = HttpContext.Current.Request;
        var resp = HttpContext.Current.Response;

        if (req.HttpMethod == "OPTIONS")
            //These headers are handling the "pre-flight" OPTIONS call sent by the browser
            resp.AddHeader("Access-Control-Allow-Methods", "GET, POST");
            resp.AddHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, SOAPAction");
            resp.AddHeader("Access-Control-Max-Age", "1728000");

Method 14

I was getting this error until I added (as shown in the code below) $.holdReady(true) at the beginning of my web service call and $.holdReady(false) after it ends. This is jQuery thing to suspend the ready state of the page so any script within document.ready function would be waiting for this (among other possible but unknown to me things).

<span class="AjaxPlaceHolder"></span>
<script type="text/javascript">
function GetHTML(source, section){
    var divToBeWorkedOn = ".AjaxPlaceHolder";
    var webMethod = "../MyService.asmx/MyMethod";
    var parameters = "{'source':'" + source + "','section':'" + section + "'}";

        type: "POST",
        url: webMethod,
        data: parameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: true,
        xhrFields: {
            withCredentials: false
        crossDomain: true,
        success: function(data) {
            var myData = data.d;
            if (myData != null) {
        error: function(e){
GetHTML("external", "Staff Directory");

Method 15

Make sure you disable custom errors. This can mask the original problem in your code:


<customErrors defaultRedirect="~/Error" mode="On">


<customErrors defaultRedirect="~/Error" mode="Off">

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x