StateDependency instead of ServiceDependancy

Topics: Web Client Software Factory, Project Management Forum, UIP Application Block discussion, User Forum
Jun 27, 2008 at 2:46 PM

I want to create a new WCF-service proxy (proxy) for each user. I dont want to share the proxy between users of my application, I dont want a singleton service so using ServiceDependancy is not a possibility.

Can I instead use StateDependancy? I want to create a service/proxy for every loggin and save that service/proxy somewhere so it is available in all module controllers just like the singleton service when using ServiceDependancy. The difference is that I want each session to has its own instance.

Could this be a solution:

In my Authenticate.aspx code-behind:

Session.Add("MyService", new MyService());

In module controllers:

private MySerivce myService;

public customerController([StateDependency("MyService")] StateValue(MyService) injectedService)
    myService = injectedService.Value;

What if I want to use out-of-process state? State Service. Will it still work? In-process state is not very reliable so I will concider to change to out-of-process. Any thoughts anyone?
Jul 1, 2008 at 7:58 AM
For the records I'll answer this myself. The solution above works like a charm and gives me the functionality I want.
But I'm not sure what happens if or when I switch to use a state server to store my session, but I'll guess it will work the same.

If anyone has more experience with this than me let me know.