c# – Wrong message in webservice integrating with ActionScript

Question:

I'm doing a restful application in C#, in which I will receive a request via post and I will return a JSON or string to the requester.

[HttpPost]
    public string confirmahora()
    {         
        String OUTPUT = "mensagem";

        HttpConfiguration config = new HttpConfiguration();
        config.Formatters.Remove(config.Formatters.JsonFormatter);   

        return resposta;
    }

But when the application in Flash (ActionScript) receives the following header:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">"mensagem"</string>

It would only have to see the word "message".

Answer:

Before returning the response, make sure the response header will return text/plain , like this:

[HttpPost]
public string confirmahora()
{         
    String OUTPUT = "mensagem";

    HttpConfiguration config = new HttpConfiguration();
    config.Formatters.Remove(config.Formatters.JsonFormatter);
    System.Web.HttpContext.Current.OutgoingResponse.ContentType = "text/plain";

    return resposta;
}
Scroll to Top