Web services webservice调用不断返回json

Web services webservice调用不断返回json,web-services,Web Services,我只是想测试对简单Web服务的一个非常简单的ajax调用。我使用的是.NET4,iis 6。我的Web服务代码如下所示 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Script.Services; using System.Web.Script.Serialization; name

我只是想测试对简单Web服务的一个非常简单的ajax调用。我使用的是.NET4,iis 6。我的Web服务代码如下所示

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

namespace ABCNamespace    {
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class MyService : System.Web.Services.WebService
{
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string HelloWorld()
    {
        return new JavaScriptSerializer().Serialize("Hello World");
    }
}
}
我的电话是这样的

$.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "../../MyService.asmx/HelloWord",
            data: "{}",
            dataType: "json",
            success: function () { alert('done'); },
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
                alert("Status: " + textStatus); alert("Error: " + errorThrown); 
            }
        });
我不断收到500个错误,仔细查看之后,我得到的是一个字符串,而不是json数据。我想如果纠正这个,它会解决我的问题。但是,我无法让它返回json数据

下面是通过调用我的webmethod进行的响应检查

 <?xml version="1.0" encoding="UTF-8"?>
 <string xmlns="http://tempuri.org/"> "Hello World" </string>

“你好,世界”

注意:请忽略我在url中使用.././而不是resolveURL这一事实。这只是为了快速简单的测试目的。我也会使用web.config处理程序,但运气不好。不确定我错过了什么…

看看类型,应该是get..type:“get”我试过get,但没有luckI觉得它可能与我的web.config有关?但据我所知,如果我使用的是.net 4I,我不需要对web.config做任何特殊的处理,我发现并解决了这个问题。我的ScriptHandlerFactory版本错误。