在某些情况下,我的行为是没有回报的。在这些情况下,这种行动本质上是这样的:
[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,以便脚本看到空字符串响应,并继续正常工作?
附加- visual服务器也返回空字符串。与IIS7.5应用程序相同的文件夹设置返回null。
来自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的响应为null值:
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
发布于 2014-03-10 19:37:58
将应用程序池从ASP.NET v4.0
切换到ASP.NET v4.0 Classic
,将不再发送Content-Type
:
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
https://stackoverflow.com/questions/22308803
复制相似问题