不使用的System.Web时OWIN,而不是使用的HttpContext什么 [英] What to use instead of HttpContext when using OWIN without System.Web

查看:290
本文介绍了不使用的System.Web时OWIN,而不是使用的HttpContext什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们有我们已经接线使用OWIN一个NancyFx项目。我们不使用的System.Web,我们需要一些地方把我们的背景下,生活比其他的HttpContext一个请求的生命。我们已经开始执行的线程静态变量的上下文,所以我们可以在任何地方访问上下文中的应用程序,但我们担心使用异步调用将失去这个线程静态上下文。

We currently have a NancyFx project that we have wired up using OWIN. We are not using System.Web and we need some place to put our context that lives for the life of a request other than HttpContext. We have started implementing the context on a thread static variable so we can access the context anywhere in the application but we are worried that using Async calls will lose this thread static context.

你有什么作为静态访问中的HttpContext的攻略,当你从System.Web程序离婚自己使用?

What do you use as a static accessor in lue of HttpContext when you divorce yourself from System.Web?

推荐答案

您可以使用NancyContext来代替。在NancyContext的项目字典是用于存储每个请求的对象。该NancyContext可在一个应用程序南希最任意位置。

You can use the NancyContext instead. The Items dictionary on the NancyContext is for storing per-request objects. The NancyContext is available most anywhere in a Nancy application.

这篇关于不使用的System.Web时OWIN,而不是使用的HttpContext什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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