ASP.net WebMethod返回完整的页面内容而不是JSON数据

时间:2012-05-27 18:04:34

标签: jquery asp.net .net ajax json

我正在为文本框尝试自动完成功能,我向webmethod发送get请求,返回完整的页面内容而非实际数据,如下所示。

enter image description here

我正在使用以下C#代码,而我使用Post请求的所有其他方法都正常工作

[WebMethod]
        [ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]
        public static string GetListOfUsers()
        {
            return "{'0701414001','0701414002'}";
        }

2 个答案:

答案 0 :(得分:0)

我认为问题在于您的参数:您正在调用Email.aspx/GetListOfUusers?query=lkkjlk,但您的public static string GetListOfUsers()不包含参数名称。

尝试更改为:

public static string GetListOfUsers(string query)
{
...
}

我还尝试将其删除:ResponseFormat=ResponseFormat.Json,看看它是否有任何改变。

答案 1 :(得分:0)

相关问题