4

I have a website with a lot of traffic, and a lot of webservice calls. All of my webservices work 95% of the time, but a couple of times a day I get this error message in my log:

Request format is unrecognized for URL unexpectedly ending in '/MyWebServiceName'.

I have Googled this problem, and all I find are pages referencing this issue: Request format is unrecognized for URL unexpectedly ending in

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

Anyone have any idea on what might cause this?

Info:

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

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 the webservice through my browser I do get data back (look above), but I wonder why it sometimes fails.

Community
  • 1
  • 1
Martin at Mennt
  • 5,677
  • 13
  • 61
  • 89
  • possible duplicate of [Request format is unrecognized for URL unexpectedly ending in](http://stackoverflow.com/questions/657313/request-format-is-unrecognized-for-url-unexpectedly-ending-in) – Fenton Jan 26 '12 at 13:24
  • Did you not see my comment in the post? I inform of the link to that post, but I do not think it applies to my issue. – Martin at Mennt Feb 07 '12 at 19:17
  • Your ajax request does a POST. Could you have a look at what happens when you visit the same url with a different type of request? (e.g GET). Could it be that "Request format is unrecognized for URL unexpectedly ending in '/MyWebServiceName'." appears only when the type of request is not supported, for example when a user opens the link in his browser. – Teisman Jan 16 '13 at 11:16

1 Answers1

0

You have dataType: 'json' but the webservice respones as xml.

Granit
  • 188
  • 1
  • 11