0

我有一个 MVC 4 应用程序,它正在接收数据并将 Json 字符串返回给客户端。该代码在 Chrome、Firefox 和 IE 中完美运行(仅针对 8+ ......但我实际上已经看到它在 IE7 中运行)。但是,它不能在 Windows 上的 Safari 5.x 中工作(我没有 Mac ......所以我无法测试它)。

这是 jQuery ......(使用 1.9.1 ......谢谢 Tim B James 的提问......之前忘了提)

$.ajax({
        type: 'POST',
        url: '@Url.Content("~/Request/ValidateApprover/")',
        data: { 'name': input },
        success: function (json) {
          //do some work here
        },
        error: function () {
          //tell the user that it failed here
        }
      });

这是我的控制器被调用...

[HttpPost]
public ActionResult ValidateApprover()
{
  string emailAddress = "";
  string name = this.Request.Form["name"]; //<--the form is blank using Safari 5

  if (String.IsNullOrEmpty(name) || String.IsNullOrWhiteSpace(name))
    return Json(new { result = "blank" }, "application/json", JsonRequestBehavior.AllowGet);

  //...keep going if you got a value other than blank

当我尝试使用 读取控制器中的结果this.Request.From["name"]时,使用 Firefox、Chrome 和 IE 时我很好……但使用 Safari 时我得到一个空白表单值。

编辑 1:我写了一个非常简单的 PHP 页面来检查数据是否在 Safari 中正确传递。看来是……所以看起来 IIS 和 Safari 之间的问题是问题所在。

编辑 2:我编写了一个非常简单的 MVC 应用程序进行测试,并且在该测试中遇到了数据......这让我相信这是 Safari 中的某种 HTML 验证。我还在此编辑中删除了已发布的请求标头数据。

有什么额外的想法吗?

4

3 回答 3

0

这就是我使用的:

功能集内容(内容文件){

if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
}
else{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState==4  && xmlhttp.status==200 ){
        //alert(xmlhttp.responseText);
      $('#*******').html(xmlhttp.responseText);
    }
}
xmlhttp.open("GET",contentfile,true);
xmlhttp.send();

}

它适用于所有浏览器。

于 2013-03-20T15:55:18.310 回答
0

问题在于 Safari 对 Kerberos 身份验证的处理,但我找到了解决方案。

http://forums.iis.net/t/1182376.aspx/1

IIS 上的那个线程描述了Negotiate(即Kerberos)身份验证在 Safari 中处理不当。您必须禁用Negotiate作为提供者。

在 IIS(我使用的是 IIS 7.5)中,点击您的站点,然后Authentication(双击)→ Windows Authentication(单击)→ Providers(在右侧)→Remove Negotiate and leave NTLM

这解决了我在 Safari 上的所有问题。

于 2013-04-10T12:46:21.423 回答
0

它也对我有用.. 我正在使用 IIS 6.0,我已经完成了。

然后以管理员身份运行“命令提示符”

cd c:\inetPub

cd adminScripts

cscript adsutil.vbs 获取 w3svc/NTAuthenticationProviders

cscript adsutil.vbs 设置 w3svc/NTAuthenticationProviders “NTLM”

重新启动 IIS。

于 2013-10-18T06:56:30.633 回答