开发者

Set MaxAllowedContentLength/maxRequestLength value per action

开发者 https://www.devze.com 2022-12-20 10:28 出处:网络
How do I set maxAllowedContentLength value per action? I have a few actions that used to upload files, each one needs a different maxAllowedContentLength value.

How do I set maxAllowedContentLength value per action?

I have a few actions that used to upload files, each one needs a different maxAllowedContentLength value.

It make sense that we don't want to use action filters as we want to filter this request at IIS level. On the other hand, action filter is the best solution from coding perspective, as they coming after the routes, so I the routes change, it continue work.

In IIS6 I know we can use <location> tag to specify maxRequestLength to a specific location. I don't know how to use this approach on IIS7, and I don't like this approach, since the url routes 开发者_如何学Care hand coded in the web.config.

What is the best solution to solve this problem?


I didn't find a way to achieve that, and I don't think that there is. Probably the best thing to do is to use a different IIS Website for the file download actions, with custom web.config.


Create a separate virtual site for the area you want different filtering.

Then run this command on your IIS server. (replace [IISWebsitename])

C:\Windows\System32\inetsrv>appcmd set config "[IISWebsitename]" -section:requestFiltering -requestLimits.maxAllowedContentLength:100000000 -commitpath:apphost

That enables 100,000,000 bytes of upload data at a time for that one web site.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号