2

I was wondering whether it is possible to define web.config settings specifically for certain URLs.

For example: Let's say I have an MVC4 web site with a bunch of controllers and actions, one of which allows uploading a large file (max. 50MB). By default, the maxRequestLength is 4MB. In web.config one would then add the following rule:

<httpRuntime maxRequestLength="51200" />

However, this means that the request length is now 50MB for every action on the website. Is it possible to make custom settings for specific URLs?

3 Answers 3

1

Simply use location for setting different values. See this answer for instance How to set different Timeouts for different URLs in ASP.NET It's for setting a timeout, but it's the same...

Sign up to request clarification or add additional context in comments.

Comments

0

You can try to set it in controller itself using MaxRequestLength property, but not sure if it is possible to set it for specific action. Approach with location setting will not work, because MVC uses routing.

Comments

0

One solution can be to create a new folder and place your controllers that you need and create a web.config for that folder. And i think this is not a good approach :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.