我创建了一个带有代码后台文件的ASMX文件。它能够正常工作,但输出的是XML格式。
不过,我需要输出JSON格式。ResponseFormat配置似乎不起作用。我的代码后台如下:
[System.Web.Script.Services.ScriptService]
public class _default : System.Web.Services.WebService {
[WebMethod]
[ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
public string[] UserDetails()
{
return new string[] { "abc", "def" };
}
}