Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a simple code that needs to return string in json using a browser.

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string FunctiGetJsononName(string str)
    {
        JavaScriptSerializer ser = new JavaScriptSerializer();
        return ser.Serialize(str);
    }

The output I get is json inside of xml. I want the json without the XML.

I can't use void method as well. Also, I am using framework 4.5.2 and empty template (I can't use anything else).

share|improve this question
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public string  FunctiGetJsononName(string str){

    Context.Response.Clear();
    Context.Response.ContentType = "application/json"; 
........
}

Try this...might help u!! it helped me ...

share|improve this answer
    
Thank you for your comment, I tried that and I still get the sme result. – EsterSason Jan 11 at 9:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.