我在我的网页上登记了一个习俗成员课程。 使用Cas 温莎的Inversion Of Control,我已经将我的习俗成员类别登记为转手人(因为后者也使用一种转手服务)。
这意味着,我要求每个网络要求重新审理会员提供人的情况。 目前,它只是每个申请领域创建一次,这样,当它试图获得它所依赖的服务时,这种服务案例才被重复使用,而不必再使用。
现在,我需要找到一种办法,突然控制我的习俗成员,但我不知道如何。 我期望在“NET”框架内的某个地方开展一次紧急事件,使我能够放弃案件的创造,并将案件转至紧急情况,但我可以找到任何东西。
因此,Im使用4.0。
<><>UPDATE: 在这里,我的一些法典使你能够看到我所做的事情:
Web.Config:
<membership defaultProvider="MyMembershipProvider" >
<providers>
<clear/>
<add name="ApplicationMembershipProvider"
type="MyNamespace.MyMembershipProvider, MyAssembly"/>
</providers>
</membership>
<>成员<>
public class MyMembershipProvider : MembershipProvider
{
private IMyService myService;
public MyMembershipProvider() : base()
{
// We should use constructor injection here but since we cannot control
// the construction of this class, we re forced to create the dependency
// ourselves.
}
public override bool ValidateUser(string username, string password)
{
if (myService == null)
{
// This scope is only reached once within the browser session,
// ASP.NET keeps the instance of MyMembershipProvider in memory
// so the myService field keeps its value across web requests.
// This results in Castle Windsor (which I have configured the service
// locator to use) not being able to control the lifetime of
// the MyService instance. So, the inability of Windsor to control
// the lifetime of MembershipProvider instances, inhibits the lifetime
// management of MyService instances as well.
myService = ServiceLocator.Current.GetInstance<IMyService>();
}
return myService.ValidateUser(username, password);
}
}