开发者

ServiceHostFactory using Structuremap that relies on HttpContext

开发者 https://www.devze.com 2023-01-17 07:11 出处:网络
I have an existing Structuremap 开发者_如何学编程ApplicationRegistry that relies on HttpContext.Current.Server and also HttpContext.Current.Items (via HttpContextScoped). I\'d like to use this in my W

I have an existing Structuremap 开发者_如何学编程ApplicationRegistry that relies on HttpContext.Current.Server and also HttpContext.Current.Items (via HttpContextScoped). I'd like to use this in my WCF ServiceHostFactory, but HttpContext.Current remains belligerently null.

I am using basicHttpBinding and for the scope of the project I'm working on I'm happy to continue to rely on that being used. My understanding is that if you use basicHttpBinding you should be able to use HttpContext.Current. Since this is always null I've obviously missed something.

What might that be?


The solution was to add this attribute to my service class:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
0

精彩评论

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