Are you attaching to the event just to get the information? If you are using the default membership provider, which looks like this in the web.config:
<
membership
defaultProvider
=
"AspNetSqlMembershipProvider"
hashAlgorithmType
=
"SHA1"
>
<
providers
>
<
remove
name
=
"AspNetSqlMembershipProvider"
/>
<
add
connectionStringName
=
"LocalSqlServer"
enablePasswordRetrieval
=
"true"
enablePasswordReset
=
"true"
requiresQuestionAndAnswer
=
"false"
applicationName
=
"MonoX"
requiresUniqueEmail
=
"false"
passwordFormat
=
"Clear"
maxInvalidPasswordAttempts
=
"5"
minRequiredPasswordLength
=
"7"
minRequiredNonalphanumericCharacters
=
"0"
passwordAttemptWindow
=
"10"
passwordStrengthRegularExpression
=
""
name
=
"AspNetSqlMembershipProvider"
type
=
"MonoSoftware.MonoX.MonoXMembershipProvider, MonoX"
/>
</
providers
>
</
membership
>
Then you can access the information without having to attach to an event. Following is some example code to show how this may work.
using
MonoSoftware.MonoX.Utilities;
using
System.Web.Security;
public
partial
class
SomeClass : SomeOtherClass
{
protected
string
Email {
get
;
set
; }
protected
string
ProviderName {
get
;
set
; }
protected
string
Name {
get
;
set
; }
protected
string
UserName {
get
;
set
; }
protected
string
IsAuthenticated {
get
;
set
; }
protected
string
UserProfile {
get
;
set
; }
protected
void
Page_Load(
object
sender, EventArgs e)
{
var user = Membership.GetUser();
Email = Membership.GetUser().Email;
ProviderName = Membership.GetUser().ProviderName;
var UserGuid = SecurityUtility.GetUserId();
IsAuthenticated = SecurityUtility.IsAuthenticated().ToString();
UserName = Membership.GetUser().UserName;
var UserProfile = SecurityUtility.GetUserProfile();
}
}
You may use the data as you need in the code behind or in the aspx / ascx pages.
By "name" are you referring to the username or actual name of a person? If you want the actual name, then you probably need to implement some profile information for users.Hope that helps.