views:

48

answers:

1

I have a .NET webservice that is returns JSON.

The client-side developer now wants to send his request in GET method, putting the parameters in the querystirng.

I have enabled the GET verb in my web.config file, I have added UseHttpGet=true in the ScriptMethod attribute, and now I am able to recive the parameters.

BUT when he calls the method using the URL he gets back XML.

Can anyone tell me how he can use a simple URL to invoke the method and get JSON as a response?

My webservice:

[WebMethod]  
[ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet = true)]
public string HelloWorld(string str)
{
    return str;
}

the call he makes is http://Mysite/Service/Service.asmx/HelloWorld?str=hisValue

A: 

You have to instruct your client-side dev to set the request content-type header to 'application/json'. The service should then serialize results as JSON.

rciq