拒绝设置不安全的标头"Connection" AjaxPro AjaxMethod [英] Refused to set unsafe header "Connection" AjaxPro AjaxMethod

查看:293
本文介绍了拒绝设置不安全的标头"Connection" AjaxPro AjaxMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AjaxPro.呼叫GetReturns()时出现此错误:

I am using AjaxPro. I am getting this error while calling GetReturns():

拒绝设置不安全的标题连接"

Refused to set unsafe header "Connection"

Report.Areas_Report.GetReturns(30, aoData, (response) => {
  if (response.error == null) {
    var myObject = response.value;
    fnCallback(myObject);
  } else {
    $.growl.error({ 
      message: "An error occurred. Please try again." 
    });
  }
  $(_overlayElementId).remove();
});

[AjaxMethod]
public DataTableResult GetReturns(int days, List<DataTableAjaxPostModel> model = null)
{
  var dataTableRequest = DataTableModelBinder.FilterDateTableRequest(model);
  var result = reportsService.GetReturns(warehouseId, days, dataTableRequest);
  return result;
}

推荐答案

这是由Chrome中的更新引起的问题.不幸的是,AjaxPro构建尚未更新以反映这一点.仍然有一种简单的方法可以解决该问题.您只需要拥有自己的AjaxPro版本,然后从代码中删除有问题的行即可.

This is an issue caused by an update in Chrome. Unfortunately, the AjaxPro build hasn't been updated to reflect this. There is still a simple way to get it to work through. You just need to have your own version of AjaxPro and remove the offending line from the code.

您可以从Github上的 https://github.com/michaelschwarz/下载AjaxPro代码库. Ajax.NET专业版.您需要选择以zip格式下载,提取文件,将项目复制到解决方案中,然后将Web项目对AjaxPro的引用更改为来自这个新项目.

You can download the AjaxPro codebase from Github at https://github.com/michaelschwarz/Ajax.NET-Professional. You'll need to select download as zip, extract the files, copy the project to your solution, then change your web project's reference to AjaxPro to come from this new project.

接下来,在该项目的根目录中打开名为core.js的文件,并转到第445行.导致该问题的整个块都需要删除或注释掉.

Next, open the file in the root of that project called core.js and go to line 445. The whole block that causes the problem will need to be deleted or commented out.

    if(!MS.Browser.isIE) {
        this.xmlHttp.setRequestHeader("Connection", "close");
    }

保存文件,构建,错误将消失.请注意,您不需要上传core.js文件,因为它是嵌入式资源,只需将新的AjaxPro.dll放到网上即可.

Save the file, build and the error will be gone. Note that you don't need to upload the core.js file as it's an embedded resource, it's just the new AjaxPro.dll that will need to be put online.

还要注意一点,尽管该项目是.net Framework 2+的正确版本,但该项目的生成方式是AjaxPro.dll,而不是AjaxPro.2.dll的较新名称-您可以更改生成名称,也可以只更改名称在您的web.config文件中.例如

One further note, this project builds as AjaxPro.dll rather than the newer name of AjaxPro.2.dll despite being the correct version for the .net framework 2+ - you can either change the build name or just change the name in your web.config file. So for example

    <sectionGroup name="ajaxNet">
        <section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2" requirePermission="false" restartOnExternalChanges="true"/>
    </sectionGroup>

将成为

    <sectionGroup name="ajaxNet">
        <section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro" requirePermission="false" restartOnExternalChanges="true"/>
    </sectionGroup>

...以及配置文件中提及AjaxPro.2的所有其他地方都需要更改为AjaxPro

...and everywhere else in the config file that mentions AjaxPro.2 will need to be changed to AjaxPro

这篇关于拒绝设置不安全的标头"Connection" AjaxPro AjaxMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆