简体   繁体   中英

Owin Self-Hosted WebApi MaxBufferSize

When I host WebApi with IIS or WebApi Selfhost, I can set values for MaxBufferSize and MaxReceivedMessageSize.

But what about Owin Self-Host? Is there any way to define those parameters? Didn't found anything. Is there no need todo that? If there is no need, can you explain why?

As you may know, Microsoft has shifted towards middleware. This article has a ready to use example to enforce the maximum message size. Basically you need to create a class that inherits OwinMiddleware and then you can inspect your message size on the IOwinRequest interface in the current context.

It's weird that two lines of code need to be replaced by a lot of complicated code for such a 'simple' task, but that's the way it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM