Larger uploads on dynamic routes in ASP.NET MVC

Hilary CookProvider UpdatesLeave a Comment

We recently had an issue here at Raygun where we needed to increase the size of uploads that we allowed.

In ASP.NET this is a simple matter of defining a location and increasing the size of the maxRequestLength and also adding a section to allow IIS to accept requests above its default size of 30 MB.

This works fine if your route does not contain any dynamic data. Unfortunately, if it does then you are out of luck, as the location path attribute only supports static paths.

We needed to preserve the existing URL as this is used by external clients. In order to accomplish this we can use IIS URL rewrite rules to rewrite incoming requests to our dynamic route and rewrite them to a static one with the dynamic sections appended via query string.

The last piece of the puzzle is to get the controller action in question to respond to both routes. Once this is done you now have a MVC route that can upload more than the average bear, while also preserving the dynamic properties that you know and love.

Keep blasting those errors!

We would absolutely recommend Raygun to any business which relies on healthy software to serve there customers. Andrew Schofield, Chief technology officer at Timely. Take a free 14 day trial. Request a short demo of Raygun.

Leave a Reply

Your email address will not be published. Required fields are marked *