ServiceHostFactory using Structuremap that relies on HttpContext
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)]
精彩评论