I saw a similar question but it did not resolve my issue. I have a JSON web service in an ASMX file;
The code for the web method
[WebMethod]
Your missed only "static" keyword in method declaration please look into the following it should work.
FYI: All the web methods should be static
[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetUserRoles(string JSONUserCode)
{
string retRoles = string.Empty;
List roles = new List();
{... I Populate the roles here ...}
DataContractJsonSerializer serializer = new
DataContractJsonSerializer(roles.GetType());
MemoryStream ms = new MemoryStream();
serializer.WriteObject(ms, roles);
string jsonString = Encoding.Default.GetString(ms.ToArray());
ms.Close();
return jsonString;
}