Hi All,
I am having a simple web service method which returns JSON serialized response. The attribute to web method is
[WebMethod, ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
As security of the return data is not a problem, I am Get enabling the HTTP response.
On the client (browser) end, my code is as below
//Add webservice and generate javascript proxy classes.
ScriptManager manager = ScriptManager.GetCurrent(Page);
ServiceReference reference = new ServiceReference("/Services/xyz.asmx");
if(manager == null)
{
manager = new ScriptManager();
}
manager.Services.Add(reference);
Everything works smoothly but occasionally on the web server's event viewer, I see the following error
"Request format is unrecognised for URL unexpectedly ending in /SomeWebServiceWebMethod"
After fiddling through the request headers using Fiddler, I figured out that if I make direct request to the webservice link, contentType header attribute is missing and that is what throws the error.
There is a good post by scott guthrie explaining this.
I am not able to replicate the issue and not sure what removes the contentType attribute from the request header occasionally.
Your help will be highly appreciated.