I have a usercontrol where it has a MemberLogin control that takes care of member being authenticated. And somewhere also I am writing some other class in where I am trying to add some functionality to the LoggedIn even of the userconrol who has MemberLogin
(or I just want to add some functionality when use logs in) (or hook some functionality to that event)
I just want to add some functionality when use logs in
you can predefine what are the functionalities for a loggedin user...if you want to implement roles based permissions or authorization then go for roles manager...
abets
How to hook to LoggedIn event of MemberLogin control from a class
on loggedin event in your user control, call that method from class by creating a instance...
on loggedin event in your user control, call that method from class by creating a instance...
I dont get it. Could u plz give a simple example.
For instance could u give exmaple for this scenario.
When a user is logs in, from a different code ( ex: from a class) put the username in the session ( not from the code behind of the usercontrol, aspx page containing the login control)
PostAuthenticateRequest happens on every request, so use that if you want data changed for every request - ie every page. If you're fetching/updating a database then this could cause performance issues in high request situations.
If you only want to do something once, when the user logs in, then use the LoggedIn event of the Login control. Mind you, that won't get raised if the authentication cookie is still active; ie the user closes their browser, then restarts it within the session
time (20 minutes i the default).
If you only want to do something once, when the user logs in, then use the LoggedIn event of the Login control
yes, this is exactly what I want to do, except i dont want to write the code in the LoggedIn event in the code behind of the page where the Login control is sitting. I want to add a functionality from a different proejct to the LoggedIn event of the Login
control of antoher project, so that when ever I remove the former project from a site, I wouldnt need to change the code from the LoggedIn event of the later project.
Is it possible? I dont even the terms for this to google it up..
Is this other project a web project? It's difficult to share code between projects like this. If you need common code, the best solution is to create a class library project with the common code in, then reference that from both web projects.
No, its more like a different package that they will be build into different dlls and be used on the same web project.
Let me try one more time here by changing the scenario. Lets say I have a Web User Control that contains my Login Control. Can I extend the functionality of the that Login control LogedIn Event from anywhere other than the Web User Control which contains
the Login Contorl.
abets
Member
11 Points
45 Posts
How to hook to LoggedIn event of MemberLogin control from a class
Apr 15, 2012 06:11 AM|LINK
I have a usercontrol where it has a MemberLogin control that takes care of member being authenticated. And somewhere also I am writing some other class in where I am trying to add some functionality to the LoggedIn even of the userconrol who has MemberLogin (or I just want to add some functionality when use logs in) (or hook some functionality to that event)
Is it possible? If so is this the best practice?
event
ramiramilu
All-Star
95245 Points
14072 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 15, 2012 10:38 AM|LINK
you can predefine what are the functionalities for a loggedin user...if you want to implement roles based permissions or authorization then go for roles manager...
on loggedin event in your user control, call that method from class by creating a instance...
Thanks,.
JumpStart
hiza808
Member
270 Points
75 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 15, 2012 03:15 PM|LINK
http://stackoverflow.com/questions/1599698/get-userid-from-asp-net-login-control-loggedin-event
abets
Member
11 Points
45 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 16, 2012 05:11 AM|LINK
I dont get it. Could u plz give a simple example.
For instance could u give exmaple for this scenario.
When a user is logs in, from a different code ( ex: from a class) put the username in the session ( not from the code behind of the usercontrol, aspx page containing the login control)
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 16, 2012 07:54 AM|LINK
You don't need to put the user name in the Session since you can just use User.Identity.Name - that's available everywhere.
abets
Member
11 Points
45 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 16, 2012 08:37 AM|LINK
I know, that was just an example.
What i want to do is, to change the member data from some custome table, something like that.
well what I am doing write now is in global.asax im running the code in
void Application_OnPostAuthenticateRequest(object sender, EventArgs e)
{
}
Which I dont think its the best practice. Even so I dont know how to hanlde when a user logs out..
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 17, 2012 07:48 AM|LINK
PostAuthenticateRequest happens on every request, so use that if you want data changed for every request - ie every page. If you're fetching/updating a database then this could cause performance issues in high request situations.
If you only want to do something once, when the user logs in, then use the LoggedIn event of the Login control. Mind you, that won't get raised if the authentication cookie is still active; ie the user closes their browser, then restarts it within the session time (20 minutes i the default).
abets
Member
11 Points
45 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 18, 2012 05:20 AM|LINK
yes, this is exactly what I want to do, except i dont want to write the code in the LoggedIn event in the code behind of the page where the Login control is sitting. I want to add a functionality from a different proejct to the LoggedIn event of the Login control of antoher project, so that when ever I remove the former project from a site, I wouldnt need to change the code from the LoggedIn event of the later project.
Is it possible? I dont even the terms for this to google it up..
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 18, 2012 08:26 AM|LINK
Is this other project a web project? It's difficult to share code between projects like this. If you need common code, the best solution is to create a class library project with the common code in, then reference that from both web projects.
abets
Member
11 Points
45 Posts
Re: How to hook to LoggedIn event of MemberLogin control from a class
Apr 18, 2012 08:41 AM|LINK
No, its more like a different package that they will be build into different dlls and be used on the same web project.
Let me try one more time here by changing the scenario. Lets say I have a Web User Control that contains my Login Control. Can I extend the functionality of the that Login control LogedIn Event from anywhere other than the Web User Control which contains the Login Contorl.