开发者

WCF - StructureMap - Caching objects for the duration of the request only

开发者 https://www.devze.com 2022-12-24 05:25 出处:网络
So I already have a working implementati开发者_如何学Goon of StructureMap with the WCF service (including custom instance provider, behaviors, etc.)

So I already have a working implementati开发者_如何学Goon of StructureMap with the WCF service (including custom instance provider, behaviors, etc.)

When I try to have an object that is instantiated only once per user request, I use the InstanceScope.HttpContext and it throws because the context is null.

Do anyone have a proper way of doing that?


On the server-side of the WCF service? By default, WCF has nothing to do with ASP.NET and thus all your HttpContext etc. aren't there.

By default, your WCF services will be called on a "per-call" basis, e.g. each request gets a brand-new, separate, totally isolated instance of your service class. Why not just put those things into the service class as internal fields??

Or you might want to check out this blog post on how to abstract request state and providing sample implementations for ASP.NET (using HttpContext.Items) and WCF.

0

精彩评论

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

关注公众号