I have the following method:
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using
Just a doubt. When are you not getting a JSON response? Because when you invoke the web service from the client (I am assuming a web browser, i.e. xhr), you should specify the content type header on the request as "application/json; charset=yourcharset".
I believe the above solution always returns json, no matter what the content type is specified from the client. The dotnet asmx framework allows this using the content-type header method, so the above could be classified as a hack, when a neat solution is available.
Similar question at Return Json Data from ASMX web service
This might help too -> http://forums.asp.net/p/1054378/2338982.aspx#2338982
P.S: I am assuming you are using dotnet version 4.