我创建了一个带有代码隐藏文件的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" };
}
}