Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase maxRequestLength for MVC Controller action

Can I increase maxRequestLength of ASP.NET request for MVC Controller Action?

I have an MVC controller that accepts file and it can be very large. I increased maxRequestLength in web.config, but it is security issue and the best solution for me will be have increased request length only for Upload method. Is it possible?

I tried

<location path="UploadFile">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
      <httpRuntime maxRequestLength="2097151"/>
    </system.web>
  </location>

But it didn't helped

Thank you.

like image 237
Jack Spektor Avatar asked Jun 23 '26 03:06

Jack Spektor


1 Answers

Can I increase maxRequestLength of ASP.NET request for MVC Controller Action?

AFAIK, no. But you could use a generic HTTP handler instead of a controller action and then your <location path="UploadFile"> will work. For example your handler could be placed in ~/UploadFile/upload.ashx.

like image 170
Darin Dimitrov Avatar answered Jun 24 '26 17:06

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!