Hi Jason,
Jason = help and help and help and no tire!!
THANKS, so happy to know people like you still exist in this strange
world ;-)
1. Yes
2. not directly but indirectly through my session factory)
3. I have register it but I will tell you how.
My codes:
Memberships Intefaces/Classes
namespace WebMonitorUpdate.MembershipServicesImpl
{
public class FormsAuthenticationService : IFormsAuthentication
{
public void SignIn(string systemId, string userName, bool
createPersistentCookie)
{
FormsAuthentication.SetAuthCookie(userName,
createPersistentCookie);
}
public void SignOut()
{
FormsAuthentication.SignOut();
}
}
}
------------------------------------------------------------------------------------------------
using System.Web.Security;
using WebMonitorUpdate.MembershipServices;
using WebMonitorUpdate.SQLServerServices;
namespace WebMonitorUpdate.MembershipServicesImpl
{
public class AccountMembershipService : IMembershipService
{
private MembershipProvider membershipProvider;
public AccountMembershipService()
: this(null)
{
}
public AccountMembershipService(MembershipProvider provider)
{
membershipProvider = provider ?? Membership.Provider;
}
public int MinPasswordLength
{
get
{
return membershipProvider.MinRequiredPasswordLength;
}
}
public bool ValidateUser(string systemId, string userName,
string password)
{
return membershipProvider.ValidateUser(userName + "|" +
systemId, password);
}
public MembershipCreateStatus CreateUser(string systemId,
string userName, string password, string email)
{
MembershipCreateStatus status;
membershipProvider.CreateUser(userName, password, email,
null, null, true, null, out status);
return status;
}
public bool ChangePassword(string userName, string
oldPassword, string newPassword)
{
//MembershipUser currentUser = membershipProvider.GetUser
(userName, true /* userIsOnline */);
//return currentUser != null ? currentUser.ChangePassword
(oldPassword, newPassword): false;
return membershipProvider.ChangePassword(userName,
oldPassword, newPassword);
}
}
}
-----------------------------------------------------------------------------------------
using System;
using System.Web.Security;
using WebMonitorUpdate.Models.Domains;
using WebMonitorUpdate.SQLServerServices;
using System.Collections.Specialized;
using WebMonitorUpdate.Services;
using WebMonitorUpdate.Models.DataAccessObjects;
using Castle.MicroKernel;
using NHibernate;
using Castle.MonoRail.Framework;
using WebMonitorUpdate.Helper;
using Castle.MonoRail.WindsorExtension;
namespace WebMonitorUpdate.MembershipServicesImpl
{
[FilterAttribute(ExecuteWhen.BeforeAction, typeof
(TransactionFilter), ExecutionOrder = 0)]
[FilterAttribute(ExecuteWhen.AfterAction, typeof
(TransactionFilter), ExecutionOrder = 1)]
public sealed class SQLServerMembershipProvider :
MembershipProvider
{
private IOnlineSystemService service = null;
private string applicationName;
private int maxInvalidPasswordAttempts;
private int passwordAttemptWindow;
private int minRequiredNonAlphanumericCharacters;
private int minRequiredPasswordLength;
private string passwordStrengthRegularExpression;
private bool enablePasswordReset;
private bool enablePasswordRetrieval;
private bool requiresQuestionAndAnswer;
private bool requiresUniqueEmail;
#region Settings
public override string ApplicationName
{
get { return this.applicationName; }
set { this.applicationName = value; }
}
public override int MaxInvalidPasswordAttempts { get { return
this.maxInvalidPasswordAttempts; } }
public override int PasswordAttemptWindow { get { return
this.passwordAttemptWindow; } }
public override int MinRequiredNonAlphanumericCharacters { get
{ return this.minRequiredNonAlphanumericCharacters; } }
public override int MinRequiredPasswordLength { get { return
this.minRequiredPasswordLength; } }
public override string PasswordStrengthRegularExpression { get
{ return this.passwordStrengthRegularExpression; } }
public override bool EnablePasswordReset { get { return
this.enablePasswordReset; } }
public override bool EnablePasswordRetrieval { get { return
false; } }
public override bool RequiresQuestionAndAnswer { get { return
this.requiresQuestionAndAnswer; } }
public override bool RequiresUniqueEmail { get { return
this.requiresUniqueEmail; } }
public override MembershipPasswordFormat PasswordFormat
{
get { return MembershipPasswordFormat.Hashed; }
}
#endregion
public SQLServerMembershipProvider()
{
IKernel kernel =
WindsorContainerAccessorUtil.ObtainContainer().Kernel;
IDaoFactory daoFactory = kernel.Resolve<IDaoFactory>();
this.service = new OnlineSystemService(daoFactory);
}
public SQLServerMembershipProvider(IDaoFactory daoFactory)
{
this.service = new OnlineSystemService(daoFactory);
}
[SkipFilter]
public override void Initialize(string name,
NameValueCollection config)
{
base.Initialize(name, config);
this.ApplicationName = GetConfigValue(config
["applicationName"],
System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
..... //other confs
}
public override bool ChangePassword(string username, string
oldPassword, string newPassword)
{
//username and systemId1 are splited by |
if (!String.IsNullOrEmpty(username))
{
//using (ISession session = this.session)
//{
//using (ITransaction tx = session.BeginTransaction())
//{
OnlineSystem system =
this.service.getCustomerInfoByName(username);
if (system == null) return false;
if (!CheckPassword(oldPassword, system.Password))
return false;
ValidatePasswordEventArgs args = new
ValidatePasswordEventArgs(username, newPassword, false);
OnValidatingPassword(args);
if (args.Cancel)
{
if (args.FailureInformation != null)
throw args.FailureInformation;
else
throw new MembershipPasswordException("Change
password canceled due to new password validation failure.");
}
system.Password = HashPassword(newPassword);
//tx.Commit();
//}
//}
}
else
{
return false;
}
return true;
}
/*
* This method check whether the username/system ID and
password match together for a user!
*/
[SkipFilter]
public override bool ValidateUser(string usernameAndSystemId,
string password)
{
string[] temp = usernameAndSystemId.Split('|');
string username = temp[0];
int systemId;
if (!String.IsNullOrEmpty(temp[1]) && int.TryParse(temp
[1], out systemId) && !String.IsNullOrEmpty(username))
{
OnlineSystem system =
this.service.getCustomerInfoByName(username);
if (system == null) return false;
if (!CheckPassword(password, system.Password) ||
system.SS20Id != systemId) return false;
return true;
}
else
{
return false;
}
}
/*
* Since the login process need username and system id GetUser
should be overrde!
* if user is online the information should be pass otherwise
not.
*/
[SkipFilter]
public override MembershipUser GetUser(string username, bool
userIsOnline)
{
MembershipUser user = null;
if (!String.IsNullOrEmpty(username) && userIsOnline)
{
OnlineSystem system =
this.service.getCustomerInfoByName(username);
if (system != null)
{
user = new MonitorUser(this.Name,
system.LoginName,
system.SS20Id,
string.Empty,
string.Empty,
string.Empty,
true,
false,
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue,
system);
}
}
return user;
}
#region Helper Methods
[SkipFilter]
private bool CheckPassword(string password, string dbpassword)
{
return BCrypt.CheckPassword(password, dbpassword);
}
[SkipFilter]
private string HashPassword(string password)
{
return BCrypt.HashPassword(password, BCrypt.GenerateSalt
(10));
}
[SkipFilter]
private string GetConfigValue(string configValue, string
defaultValue)
{
if (String.IsNullOrEmpty(configValue))
return defaultValue;
return configValue;
}
#endregion
}
}
_____________________________________________________________________________________________________________________________________________________________________
My NHibernateDaoFactory: IDaoFactory look like so (OnlineSystemDao and
VersionUpdateDao and PatchDao are my DAOs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
using Castle.MicroKernel;
using WebMonitorUpdate.Models.DataAccessObjects;
namespace WebMonitorUpdate.Models.NHDataAccessObjects
{
public class NHibernateDaoFactory : IDaoFactory
{
private IKernel kernel;
private IOnlineSystemDAO onlineSystemDAO = null;
private IVersionUpdateDAO versionUpdateDAO = null;
private IPatchDAO patchDAO = null;
public NHibernateDaoFactory(IKernel kernel)
{
this.kernel = kernel;
}
public IOnlineSystemDAO GetOnlineSystemDAO()
{
if (this.onlineSystemDAO == null)
{
this.onlineSystemDAO =
this.kernel.Resolve<IOnlineSystemDAO>();
}
return this.onlineSystemDAO;
}
public IVersionUpdateDAO GetVersionUpdateDAO()
{
if (this.versionUpdateDAO == null)
{
this.versionUpdateDAO =
this.kernel.Resolve<IVersionUpdateDAO>();
}
return this.versionUpdateDAO;
}
public IPatchDAO GetPatchDAO()
{
if (this.patchDAO == null)
{
this.patchDAO = this.kernel.Resolve<IPatchDAO>();
}
return this.patchDAO;
}
}
}
_____________________________________________________________________________________________________________________________________________________________________
I have registered component some in web.config and some directly with
c# codes (I am very confused in this point):
web.config:
....
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="WebMonitorUpdate">
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</
property>
<property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
<property name="connection.connection_string">Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|
WebMonitorUpdate.mdf;Integrated Security=True;User Instance=True</
property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</property>
<property name="current_session_context_class">web</property>
<property name="show_sql">true</property>
<mapping assembly ="WebMonitorUpdate" />
</session-factory>
</hibernate-configuration>
<castle>
<facilities>
<facility
id="NHibernateFacility"
type="WebMonitorUpdate.Helper.NHibernateFacility,
WebMonitorUpdate">
<!--isWeb="true"
//The following does not require since I have nhibernate conf
above!!
<factory id="sessionFactory1">
<settings>
<item
key="connection.provider">NHibernate.Connection.DriverConnectionProvider</
item>
<item
key="connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
<item key="connection.connection_string">Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|
WebMonitorUpdate.mdf;Integrated Security=True;User Instance=True</
item>
<item
key="dialect">NHibernate.Dialect.SQLAnywhere10Dialect,
WebSupportLog.Data</item>
<item
key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</item>
<item key="current_session_context_class">web</item>
<item key="show_sql">true</item>
</settings>
<assemblies>
<assembly>WebMonitorUpdate</assembly>
</assemblies>
</factory>-->
</facility>
<!--<facility id="FactorySupportFacility"
type="Castle.Facilities.FactorySupport.FactorySupportFacility,
Castle.MicroKernel" />-->
</facilities>
<components>
<!-- Services-->
<component id="AccountMembershipService"
service="WebMonitorUpdate.MembershipServices.IMembershipService,
WebMonitorUpdate"
type="WebMonitorUpdate.MembershipServicesImpl.AccountMembershipService,
WebMonitorUpdate"
lifestyle="transient">
</component>
<!-- Factories -->
<component id="ControllerFactory"
service="System.Web.Mvc.IControllerFactory,
System.Web.Mvc, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
type="WebMonitorUpdate.Helper.ControllerFactory,
WebMonitorUpdate"
lifestyle="transient">
</component>
<component id="DaoFactory"
service="WebMonitorUpdate.Models.DataAccessObjects.IDaoFactory,
WebMonitorUpdate"
type="WebMonitorUpdate.Models.NHDataAccessObjects.NHibernateDaoFactory,
WebMonitorUpdate"
lifestyle="transient">
</component>
<!-- Data Access Objects -->
<component id="OnlineSystemDAO"
service="WebMonitorUpdate.Models.DataAccessObjects.IOnlineSystemDAO,
WebMonitorUpdate"
type="WebMonitorUpdate.Models.NHDataAccessObjects.OnlineSystemDAO,WebMonitorUpdate"
lifestyle="transient">
</component>
<component id="VersionUpdateDAO"
service="WebMonitorUpdate.Models.DataAccessObjects.IVersionUpdateDAO,
WebMonitorUpdate"
type="WebMonitorUpdate.Models.NHDataAccessObjects.VersionUpdateDAO,WebMonitorUpdate"
lifestyle="transient">
</component>
<component id="PatchDAO"
service="WebMonitorUpdate.Models.DataAccessObjects.IPatchDAO,
WebMonitorUpdate"
type="WebMonitorUpdate.Models.NHDataAccessObjects.PatchDAO,WebMonitorUpdate"
lifestyle="transient">
</component>
</components>
</castle>
....
--------------------------------------------------------------
app_start:
private void RegisterComponents(IKernel kernel)
{
kernel.Register(
// Register all controllers in assembly.
AllTypes
.Of<IController>()
.FromAssembly(typeof(MvcApplication).Assembly)
.Configure(
reg =>
reg.Named
(reg.Implementation.Name.ToLowerInvariant()).LifeStyle.Transient),
// Register all services in assembly (I have created
an Interface (empty) and all my services implement this interface
(IService) .
AllTypes
.Of<IService>()
.FromAssembly(typeof(MvcApplication).Assembly)
.Configure(
reg =>
reg.Named
(reg.Implementation.Name.ToLowerInvariant()).LifeStyle.Transient),
// Register Transaction filter
Component
.For<Castle.MonoRail.Framework.Filter>()
.ImplementedBy<TransactionFilter>()
.LifeStyle.Singleton
);
}
_____________________________________________________________________________________________________________________________________________________________________
One of my services which implement IService (empty Interface):
namespace WebMonitorUpdate.SQLServerServices
{
public sealed class OnlineSystemService : IOnlineSystemService
{
public IOnlineSystemDAO SystemDAO
{
get;
set;
}
public OnlineSystemService(IDaoFactory daoFactory)
{
this.SystemDAO = daoFactory.GetOnlineSystemDAO();
}
public OnlineSystem getCustomerInfoByNameAndSystemId(string
username, int systemId)
{
OnlineSystem user =
this.SystemDAO.findByUsernameAndSystemId(username, systemId);
return user;
}
public OnlineSystem getCustomerInfoByName(string username)
{
OnlineSystem user = this.SystemDAO.findByUsername
(username);
return user;
}
}
}
_____________________________________________________________________________________________________________________________________________________________________
I WILL BE MORE THANKFUL if you help me to solve to use IHttpModule
(SessionScope) for session management. I have solved it through a fake
solution which I am not satisfied at all.
anywhere I use session, I control the session if it is not active
then: getCurrentSession through resolving the container
(WindsorContainerAccessorUtil.obtaincontainer()...)
THANKS ^ 1000000 for your time and help and everything.
/Sheri
_____________________________________________________________________________________________________________________________________________________________________
On 27 Jan, 16:20, Jason Meckley <[email protected]> wrote:
> you lost me :) i think I get it, but want to be sure.
> 1. you are subclassing asp.net MembershipProvider
> 2. your implementation utilizes ISession
> 3. your implementation isn't registered in the container and therefore
> cannot be resolved automatically
>
> I haven't used the MembershipProvider explicitly. The apps I create
> are intranet apps on a Windows Domain. We utlize windows
> authentication, so I'm haven't had to explicitly control the login
> process.
>
> can you post the relevant code for the provider (and associated
> objects)? We should be able to get this to work.
>
> On Jan 27, 9:00 am, Sheri <[email protected]> wrote:
>
>
>
> > Jason, thanks again for your quick answer!
>
> > All of component who injects session are transient.
> > The only thing that I can guess is "MembershipProvider" in ASP .NET
> > MVC. I cannot register it as a component. and since I user one of my
> > services in my costumized provider I should register this one as a
> > transient component too but I cannot do.
>
> > Is it true? what can I use instead of OoTB "Membership Provider" in
> > ASP .NET MVC 1.0?
>
> > /Sheri
>
> > On 26 Jan, 22:32, Jason Meckley <[email protected]> wrote:> if you are
> > injecting the session into a service, the service must be
> > > Transient, also with objects that utilize these service must be
> > > transient. here are some examples
>
> > > controller > dao > session. all must be transient
> > > controller > service
> > > > dao > session. controller and dao must be transient,
> > > service can be a singleton, if necessary.
>
> > > by default component lifestyles are "undefined" which defaults to
> > > singletons.
>
> > > On Jan 26, 3:54 pm, Sheri <[email protected]> wrote:
>
> > > > ______________________
> > > > By the way the error message is (sorry for swedish language in the
> > > > message):
>
> > > > System.ObjectDisposedException was unhandled by user code
> > > > Message="Session is closed!\r\nObjektnamn: ISession."
> > > > Source="NHibernate"
> > > > ObjectName="ISession"
> > > > StackTrace:
> > > > vid NHibernate.Impl.AbstractSessionImpl.ErrorIfClosed()
> > > > vid
> > > > NHibernate.Impl.AbstractSessionImpl.CheckAndUpdateSessionStatus()
> > > > vid NHibernate.Impl.SessionImpl.CreateCriteria(Type
> > > > persistentClass, String alias)
> > > > vid
> > > > WebMonitorUpdate.Models.NHDataAccessObjects.OnlineSystemDAO.findByUsername
> > > > (String username) i C:\Projects\WebMonitorUpdate\WebMonitorUpdate
> > > > \Models\NHDataAccessObjects\OnlineSystemDAO.cs:rad 55
> > > > vid
> > > > WebMonitorUpdate.SQLServerServices.OnlineSystemService.getCustomerInfoByNam
> > > > e
> > > > (String username) i C:\Projects\WebMonitorUpdate\WebMonitorUpdate
> > > > \SQLServerServices\OnlineSystemService.cs:rad 33
> > > > vid
> > > > WebMonitorUpdate.MembershipServicesImpl.SQLServerMembershipProvider.Validat
> > > > eUser
> > > > (String usernameAndSystemId, String password) i C:\Projects
> > > > \WebMonitorUpdate\WebMonitorUpdate\MembershipServicesImpl
> > > > \SQLServerMembershipProvider.cs:rad 139
> > > > vid
> > > > WebMonitorUpdate.MembershipServicesImpl.AccountMembershipService.ValidateUs
> > > > er
> > > > (String systemId, String userName, String password) i C:\Projects
> > > > \WebMonitorUpdate\WebMonitorUpdate\MembershipServicesImpl
> > > > \AccountMembershipService.cs:rad 32
> > > > vid WebMonitorUpdate.Validators.AccountValidators.ValidateLogOn
> > > > (String systemId, String userName, String password, IMembershipService
> > > > membershipService, ModelStateDictionary modelState) i C:\Projects
> > > > \WebMonitorUpdate\WebMonitorUpdate\Validators\AccountValidators.cs:rad
> > > > 50
> > > > vid WebMonitorUpdate.Controllers.AccountController.LogOn(String
> > > > systemId, String userName, String password, Boolean rememberMe, String
> > > > returnUrl) i C:\Projects\WebMonitorUpdate\WebMonitorUpdate\Controllers
> > > > \AccountController.cs:rad 70
> > > > vid lambda_method(ExecutionScope , ControllerBase , Object[] )
> > > > vid System.Web.Mvc.ActionMethodDispatcher.Execute
> > > > (ControllerBase controller, Object[] parameters)
> > > > vid System.Web.Mvc.ReflectedActionDescriptor.Execute
> > > > (ControllerContext controllerContext, IDictionary`2 parameters)
> > > > vid System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
> > > > (ControllerContext controllerContext, ActionDescriptor
> > > > actionDescriptor, IDictionary`2 parameters)
> > > > vid
> > > > System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<InvokeActionMeth
> > > > odWithFilters>b__7
> > > > ()
> > > > vid
> > > > System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
> > > > (IActionFilter filter, ActionExecutingContext preContext, Func`1
> > > > continuation)
> > > > vid
> > > > System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<>c__DisplayClass
> > > > c.<InvokeActionMethodWithFilters>b__9
> > > > ()
> > > > vid
> > > > System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters
> > > > (ControllerContext controllerContext, IList`1 filters,
> > > > ActionDescriptor actionDescriptor, IDictionary`2 parameters)
> > > > vid System.Web.Mvc.ControllerActionInvoker.InvokeAction
> > > > (ControllerContext controllerContext, String actionName)
> > > > vid System.Web.Mvc.Controller.ExecuteCore()
> > > > vid System.Web.Mvc.ControllerBase.Execute(RequestContext
> > > > requestContext)
> > > > vid
> > > > System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute
> > > > (RequestContext requestContext)
> > > > vid System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
> > > > httpContext)
> > > > vid System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext
> > > > httpContext)
> > > > vid
> > > > System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest
> > > > (HttpContext httpContext)
> > > > vid System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest
> > > > (IHttpHandler httpHandler, HttpContextBase httpContext)
> > > > vid System.Web.Routing.UrlRoutingHandler.ProcessRequest
> > > > (HttpContextBase httpContext)
> > > > vid System.Web.Routing.UrlRoutingHandler.ProcessRequest
> > > > (HttpContext httpContext)
> > > > vid
> > > > System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest
> > > > (HttpContext context)
> > > > vid WebMonitorUpdate._Default.Page_Load(Object sender,
> > > > EventArgs e) i C:\Projects\WebMonitorUpdate\WebMonitorUpdate
> > > > \Default.aspx.cs:rad 18
> > > > vid System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr
> > > > fp, Object o, Object t, EventArgs e)
> > > > vid System.Web.Util.CalliEventHandlerDelegateProxy.Callback
> > > > (Object sender, EventArgs e)
> > > > vid System.Web.UI.Control.OnLoad(EventArgs e)
> > > > vid System.Web.UI.Control.LoadRecursive()
> > > > vid System.Web.UI.Page.ProcessRequestMain(Boolean
> > > > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> > > > InnerException:
>
> > > > ______________________
>
> > > > On 26 Jan, 21:41, Sheri <[email protected]> wrote:
>
> > > > > Thanks a lot Jason for you help.
> > > > > Sorry for my disturbance.
>
> > > > > ((just a point to them who would like to use NH 2.1.2.4000 and latest
> > > > > Castle versions, NHibernate.ByteCode.Castle source code should be
> > > > > built by the latest version of Castle.Core and Castle.DynamicProxy2.))
>
> > > > > I use IHttpModule to open/close session but I get "Session Closed"
> > > > > error.
>
> > > > > 1. web.config: I have current_session_context_class = web & <add
> > > > > name="SessionScope" type="MyPackage.Helper.SessionScope, MyPackage"/>
> > > > > in my httpModule section
> > > > > 2. I have a daoFactory which is registered in container. this
> > > > > daoFactory initialize all my DAOs. (But I do not have registered my
> > > > > dao in the container directly. DAO classes are for CRUD operation)
> > > > > 3. I have some services classes which has some dao as object for other
> > > > > process with retrieved data from DAOs. In these services classes I
> > > > > have initialized each dao through daofactory
> > > > > 4. All my daos is inserted in castle section of web.config
>
> > > > > I do not know why I get "session closed error". The only thing I can
> > > > > guess is registration in container which I have some trouble to
> > > > > understand.
> > > > > SessionScope (that implements IHttpModule) should retrieve and close
> > > > > session byself? or?
>
> > > > > Thanks for any help
>
> > > > > Regards
> > > > > Sheri
>
> > > > > On 25 Jan, 14:49, Jason Meckley <[email protected]> wrote:
>
> > > > > > Sheri, this has been my approach with registering NH in Windsor.
>
> > > > > > public NhibernateFacility : AbstractFacility
> > > > > > {
> > > > > > public override void Init()
> > > > > > {
> > > > > > var configuration = new Configuration().Configure();
> > > > > > var factory = configuration.BuildSessionFactory();
> > > > > >
> > > > > > Kernel.AddComponentInstance("nhibernate_configuration",
> > > > > > configuration);
> > > > > > Kernel.AddComponentInstance("session_factory", );
> > > > > >
> > > > > > Kernel.Resolvers.Add(NhibernateSessionResolver(Kernel));
> > > > > > //I could also use the factory method to resolve
> > > > > > the session, but
> > > > > > that can cause a memory leak if i don't also implement
> > > > > > //a custom lifecyle for it. It's easier just to
> > > > > > resolve the session
> > > > > > with sub dependency resolver.
> > > > > > //It's also easier to test in isolation.
> > > > > > }
>
> > > > > > }
>
> > > > > > public NhibernateSessionResolver : ISubDependencyResolver
> > > > > > {
> > > > > > private readonly IKernel kernel;
>
> > > > > > public NhibernateSessionResolver(IKernel kernel)
> > > > > > {
> > > > > > ...
>
> läs mer »
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.