I want to be able to detect when a user subscribes to my application using passive variables, so I can add them to my database if this is the first time I use my application. Right now I am subscribing to WSFederationAuthenticationModule.SignedIn, but I feel like I'm missing something. Basically, Iβm not sure that itβs best to sign up for an event, I got it to work inside PostAuthenticateRequest, but it hacked a bit. Any suggestions?
this code is from global.asax
public override void Init()
{
base.Init();
PostAuthenticateRequest += (s, e) =>
{
try
{
FederatedAuthentication.WSFederationAuthenticationModule.SignedIn -= SignedIn;
}
finally
{
FederatedAuthentication.WSFederationAuthenticationModule.SignedIn += SignedIn;
}
};
}
private void SignedIn(object sender, EventArgs e)
{
}
EDIT:
, , SignedIn. - , :) . .
private static bool isFirstRequest = true;
public override void Init()
{
base.Init();
PostAuthenticateRequest += (s, e) => {
if (isFirstRequest)
{
FederatedAuthentication
.WSFederationAuthenticationModule.SignedIn += SignedIn;
isFirstRequest = false;
}
};
}
private void SignedIn(object sender, EventArgs e)
{
}
EDIT:
. , azure, , , . , , , .