Jquery 将MVC3应用程序从IIS 6移动到IIS 7.5-Ajax响应值不同?

Jquery 将MVC3应用程序从IIS 6移动到IIS 7.5-Ajax响应值不同?,jquery,asp.net-mvc,iis-7.5,iis-6,Jquery,Asp.net Mvc,Iis 7.5,Iis 6,在某些情况下,我的行为不会返回任何结果。在这些情况下,基本上是这样的: [HttpGet] [NoCache] public JsonResult Search(SearchCriteriaModel search) { var searchResults = Searcher.PerformSearch(search); //searchResults == null return Json(searchResults, JsonRequestBehavior.Al

在某些情况下,我的行为不会返回任何结果。在这些情况下,基本上是这样的:

[HttpGet]
[NoCache]
public JsonResult Search(SearchCriteriaModel search)
{
    var searchResults = Searcher.PerformSearch(search); 

    //searchResults == null
    return Json(searchResults, JsonRequestBehavior.AllowGet);
}
这是通过jQuery调用的:

$.ajax({
    url: "the url",
    type: "GET",
    data: {search criteria},
    success: function(response) {
        /*
            in iis6 'response' === ''
            in iis7.7 'response' === null, causing an error later
    */
    }
});
在ii6中,响应是一个空字符串。在iis7.5中,响应为
null

为什么剧本会有所不同

如何配置iis7.5,使脚本看到空字符串响应,并继续正常工作

附加-VisualStudioWeb服务器也返回空字符串。与IIS7.5应用程序完全相同的文件夹设置返回空值

visual studio web服务器对空字符串值的响应:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 10 Mar 2014 19:22:29 GMT
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Length: 0
Connection: Close
IIS7.5对空值的响应:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 10 Mar 2014 19:22:32 GMT
Content-Length: 0

将应用程序池从
ASP.NET v4.0
切换到
ASP.NET v4.0 Classic
,将不再发送
内容类型

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 0
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
X-Powered-By: ASP.NET
Date: Mon, 10 Mar 2014 19:37:28 GMT

我觉得这与现在发送的
内容类型:application/json
头有关。因此,现在将空响应转换为空javascript对象,而不是空字符串。你用的是什么版本的jQuery?@StevenV我同意一定是这样。我正在运行1.7.2,该应用程序有点旧。@StevenV看起来像是应用程序池,感谢您的关注。