增加MVC Controller动作的maxRequestLength

问题描述

| 我可以增加MVC控制器操作的ASP.NET请求的maxRequestLength吗? 我有一个接受文件的MVC控制器,它可能很大。我在web.config增加了maxRequestLength,但这是安全性问题,对我来说最好的解决方案是仅对Upload方法增加请求长度。可能吗? 我试过了
<location path=\"UploadFile\">
    <system.web>
      <authorization>
        <allow users=\"*\"/>
      </authorization>
      <httpRuntime maxRequestLength=\"2097151\"/>
    </system.web>
  </location>
但这并没有帮助 谢谢。     

解决方法

  我可以增加MVC控制器操作的ASP.NET请求的maxRequestLength吗? AFAIK,不。但是您可以使用通用HTTP处理程序代替控制器操作,然后您的
<location path=\"UploadFile\"
>将起作用。例如,您的经理可以放在
~/UploadFile/upload.ashx
中。