Owin 自托管 WebApi MaxBufferSize [英] Owin Self-Hosted WebApi MaxBufferSize

查看:80
本文介绍了Owin 自托管 WebApi MaxBufferSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 IIS 或 WebApi Selfhost 托管 WebApi 时,我可以设置 MaxBufferSize 和 MaxReceivedMessageSize 的值.

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

但是 Owin 自托管呢?有没有办法定义这些参数?没有发现任何东西.没有必要这样做吗?如果没有必要,你能解释一下原因吗?

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?

推荐答案

如您所知,Microsoft 已转向中间件.这篇文章已准备就绪使用示例来强制最大消息大小.基本上,您需要创建一个继承 OwinMiddleware 的类,然后您可以在当前上下文中检查 IOwinRequest 接口上的消息大小.

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.

这篇关于Owin 自托管 WebApi MaxBufferSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆