如何在chrome浏览器中解决413错误

时间:2017-12-30 16:02:38

标签: c# jquery asp.net ajax google-chrome

Ι在jQuery中有以下代码

var method = "SaveUploadedOffer";
var url = "/Handler/UserControlHandler.ashx";
  var data = { 'method': method, 'UploadedObj': 
            JSON.stringify(ko.toJS(Selected))};
            $.post(url, data,
                    function (result) {    
                    $("#preloader").css("display","block");                
                        var obj=jQuery.parseJSON(result);
                        if (obj.IsSucess==true) { 
                            self.SelectedPurpose(null);
                            self.SelectedPropertyType(null);
                            jAlert(obj.Message,"Alert...");    
                            $("#preloader").css('display', 'none');    
                            if(obj.Message=="Session expired, please login to continue")
                            {
                                    $('#popup_ok').on('click', function(e){ 
                                     window.location = "../rental/home.aspx";             
                                });
                            }
                            else
                            {
                                 $('#popup_ok').on('click', function(e){ 
                                     window.location = "../user/dashboard.aspx";             
                                });
                            }

                        }
                        else {

                            jAlert("Something went wrong, please try again later","Error...");  
                            $("#preloader").css("display","block");                        
                        }
                    });

此代码在Firefox中运行良好,但在Chrome中它给我一个错误。

请告诉我如何解决此错误。

enter image description here

3 个答案:

答案 0 :(得分:1)

我不确定它为什么在firefox中运行,但是当请求主体大于服务器配置为允许时,会发生413 errors

在IIS中设置uploadreadaheadsize配置设置

以下是在uploadReadAheadSize

中设置IIS 8.5的步骤
  • 打开IIS
  • 在默认网站
  • 下导航
  • 向下滚动到管理并打开配置编辑器
  • 选择以下部分(在顶部下拉)system.webServer并展开它,然后找到serverRuntime
  • 您会在那里找到uploadReadAheadSize值的当前值,您可以更改

答案 1 :(得分:0)

我已将我的web.config更改为

<configuration>
    <system.web>
        <!-- This will handle requests up to 20MB -->
        <httpRuntime maxRequestLength="20480" timeout="3600" />
    </system.web>
</configuration>

<!-- IIS Specific Targeting (noted by the system.webServer section) -->
<system.webServer>
   <security>
      <requestFiltering>
         <!-- This will handle requests up to 20MB -->
         <requestLimits maxAllowedContentLength="20971520" />
      </requestFiltering>
   </security>
 </system.webServer>

现在它适用于firefox和chrome。 感谢

答案 2 :(得分:0)

如果在Chrome中,只需将浏览器重置为默认设置即可。为我工作。