理论上,OwinContext 环境应该可以访问请求/响应信息以及服务器变量,但由于某些原因,我无法访问来自 Request.ServerVariables
的一些自定义服务器变量。收藏。
是什么导致了这种差异,我应该如何解决它?
最佳答案
我自己刚刚遇到了这个。事实证明,您可以访问 HttpContextWrapper
来自 IOwinContext.Environment
:
var httpContextWrapper = owinContext.Environment["System.Web.HttpContextBase"] as HttpContextWrapper;
然后您可以访问
Request
属性(property):httpContextWrapper.Request.ServerVariables
关于.net - 无法从 OwinContext 访问某些服务器变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30219861/