Request format not recognized for URL unexpectedly ending

I have a website with lots of traffic and lots of web surfing requests. All my web services work 95% of the time, but a couple of times a day I get this error message in my log:

The request format is not recognized for URLs unexpectedly ending in '/ MyWebServiceName'.

I have a problem with Googled, and all I find are pages that link to this problem: The request format is not recognized for a URL that unexpectedly ends in

But this does not apply to me, since my web services really work most of the time. I already got this code in my web.config.

Can anyone think that can do this?

Information:

  • Windows Server 2008
  • ASP.NET 2.0 on IIS7.
  • Use jQuery to call web services.

Code Examples:

jQuery call

$.ajax({ type: 'POST', contentType: 'application/json; charset=utf-8', url: '/MyWebServiceName', dataType: 'json', success: function(msg) { // On success }, error: function(xhr, textStatus, errorThrown) { // On error } }); 

Return from webservice:

 <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/"> [{"ID":"GB","Name":"Great Britain"},{"ID":"IT","Name":"Italy"},{"ID":"DE","Name":"Germany"}] </string> 

When I call a web service through my browser, I return the data (see above), but I wonder why this sometimes fails.

+4
source share
1 answer

You have dataType: 'json', but the web service is being processed as xml.

0
source

All Articles