首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将MVC3应用程序从IIS6移到IIS7.5-AJAX响应值是否不同?

将MVC3应用程序从IIS6移到IIS7.5-AJAX响应值是否不同?
EN

Stack Overflow用户
提问于 2014-03-10 18:52:30
回答 1查看 183关注 0票数 0

在某些情况下,我的行为是没有回报的。在这些情况下,这种行动本质上是这样的:

代码语言:javascript
运行
复制
[HttpGet]
[NoCache]
public JsonResult Search(SearchCriteriaModel search)
{
    var searchResults = Searcher.PerformSearch(search); 

    //searchResults == null
    return Json(searchResults, JsonRequestBehavior.AllowGet);
}

这是用jQuery调用的:

代码语言:javascript
运行
复制
$.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服务器的具有空字符串值的响应:

代码语言:javascript
运行
复制
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值:

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-10 19:37:58

将应用程序池从ASP.NET v4.0切换到ASP.NET v4.0 Classic,将不再发送Content-Type

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22308803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档