Return JSON response from an ASP.NET web service

When working with old ASP.NET Web Services there appears to be a limitation when trying to specify the response format. In this scenario the Web Service needs to return a JSON result for use by some script components and so is decorated with the attribute

[ScriptMethod(ReponseFormat = ResponseFormat.Json)].

Although this will return a JSON string result as expected it does not seem to set the ContentType correctly, after some digging around it appears that the only solution is to force the content type in code. Although this is not ideal it seems to work.

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void MyJSONWebMethod()
{
    object myObject = new myObject();

    string result = JsonConvert.SerializeObject(myObject);

    // Required to get a pure json result
    Context.Response.Clear();
    Context.Response.ContentType = "application/json";
    Context.Response.Write(result);
}