Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to use or stimulate a very simple session object inside my WCF app.

I simply need to store some values at the beginning of a call and I need access to these values while I go through some different methods of my service.

Asp.NET session would be very ideal to use for this so I need to find out what is available on a WCF app for storing such values.

Note: this is just a per call session, I don't need to retain this session between different calls from the client to service and such..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
217 views
Welcome To Ask or Share your Answers For Others

1 Answer

What you're describing (custom context that is retained for the life of a single request) is more like HttpContext.Items than an ASP.NET Session.

WCF does have a class called OperationContext that is similar to HttpContext. It doesn't have an Items property for custom context, but this blog post describes a technique you can use to achieve what you want.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...