我有一个 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 验证。我还在此编辑中删除了已发布的请求标头数据。
有什么额外的想法吗?