3

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.

Jack Spektor
  • 1,097
  • 1
  • 11
  • 30

1 Answers1

4

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 3
    What about setting from this thread: http://stackoverflow.com/questions/492346/asp-net-mvc-and-httpruntime-executiontimeout/636609#636609 ? Does it only work for executionTimeout and not for maxRequestLength ? – jwaliszko Apr 15 '12 at 23:14