0

I have a Web API which uploads images and videos to Azure. I want to limit image size to 5 MG and videos to 100 MG but I Tried Web.config Maximum value but I don't know how to apply it on Videos and images where I need different sizes.

<system.web>
  <httpRuntime maxRequestLength="5000" />
</system.web>
<system.webServer>
  <security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="5000" />
    </requestFiltering>
  </security>
</system.webServer>

Thanks

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
Daina Hodges
  • 823
  • 3
  • 12
  • 37

1 Answers1

0

Since IIS7, the maxAllowedContentLength value is measured in bytes; that setting (5000) effectively is less than 5KB. You will need to adjust accordingly

As you do not have any code shown for your application, I can only give you general guidance. What you will need to do after you do the upload is to check the both the file's type and size. You could then apply if/then logic to depose the uploaded files as needed based on type and size

Mad Myche
  • 1,075
  • 1
  • 7
  • 15
  • I want to avoid uploading big files to protect the server from crashing or consuming my bandwidth. – Daina Hodges Feb 20 '18 at 19:48
  • You can use multiple web.config files in the same application; put your upload into a separate folder with a new .config file. See the following post for some more info: [maxAllowedContentLength vs maxrequestlength](https://stackoverflow.com/questions/6327452/which-gets-priority-maxrequestlength-or-maxallowedcontentlength) – Mad Myche Feb 20 '18 at 22:10