MVC超出最大请求长度

时间:2013-11-07 12:26:50

标签: asp.net-mvc

我有一个MVC解决方案。解决方案中有一个操作:

public FileResult ExportPdf(string pdfHtml, string pdfIdentifier)
{  
}

当我提交表单时,我的javascript使用文本数据(base64格式的当前页面的html)初始化隐藏字段 pdfHtml 。所以这个字段可能大于10mb。

function ExportPDF() {

    document.getElementById('pdfHtml').value = window.btoa(unescape(encodeURIComponent(document.getElementById('Report').outerHTML)));
    document.getElementById('exportForm').submit();
}

当我发帖时,我有一个错误

  

异常:System.Web.Services.Protocols.SoapException:   System.Web.Services.Protocols.SoapException:有一个例外   运行配置文件中指定的扩展名。 --->   System.Web.HttpException:超出最大请求长度。在   System.Web.HttpRequest.GetEntireRawContent()

我知道web.config文件中的配置。所以我这样做了:

<system.web>
<httpRuntime requestValidationMode="2.0" maxRequestLength="1147483647"  executionTimeout="200" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="3294967295" />
      </requestFiltering>
 </security>
</system.webServer>

但我仍然遇到这个错误。我对这个问题已经失去了理智,并且不知道问题是什么。

1 个答案:

答案 0 :(得分:0)

<httpRuntime maxRequestLength="1048576" requestValidationMode="2.0" enableVersionHeader="false" targetFramework="4.5" />

将此添加到您的webconfigue中。错误将解决。