开发者

what is the best Session management opt ion for Asp.net mvc - wcf - BLL - Nhibernate repository

I have an application architecture which has following layers (or c# projects).

  1. web front end (asp.net mvc2)
  2. service laye开发者_运维技巧r (normal c# class library)
  3. Model layer (normal c# class library with entities, service and repository Interfaces)
  4. Data layer (implements repository interface defined in BLL and uses NHibernate)

ISession is opened per http request and its working fine.

Now, I would like to add wcf layer on top of my current service layer. wcf project plainly calls original service layer classes. But as soon as I do this, the session/session factory at asp.net becomes unusable/unavailable. Looks like, wcf is running in totally different context than asp.net. Hence I would like to move the logic of initinializing session factory and session management to wcf. How should I do it? and even before is it a good practice? one of the reason I would like to add wcf is because I want to expose the operations to other applications (which may not be http based).

Any help, blog post or book reference would be greatly appreciated.


Use Per-call instancing of NHibernate session. Check this article. It explains how to create attribute which will attach Session to current instance context.


you probably want to have WCF running in the same context as asp.net... try this article: http://msdn.microsoft.com/en-us/library/aa702682.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜