Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7930887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:33:35+00:00 2026-06-03T20:33:35+00:00

I want to be able to detect when a user signs on to my

  • 0

I want to be able to detect when a user signs on to my application using passive acs, so that I can add them to my database if this is the first time using my app. Right now I am subscribing to WSFederationAuthenticationModule.SignedIn but I feel I’m missing something. Mainly I’m not sure the best place to subscribe to the event, I got it to work inside PostAuthenticateRequest but its a bit hacky. 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)
    {
       //do something
    }

EDIT:

For now I’m going to use a flag variable to make sure I only subscribe once to SignedIn. Unless someone has any other suggestions that is 🙂 thanks for the help Sandrino. Here is what I have at the moment.

    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)
    {

        //do something   

    }

EDIT:
A little more info. This problem happens if I’m using the azure emulator, it probably happens when deployed as well but I haven’t tried that. I have tested if I am just not able to debug by trying to write to a text file and no text file was created.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:33:36+00:00Added an answer on June 3, 2026 at 8:33 pm

    Why do you subscribe to the SignedIn event each time the PostAuthenticateRequest event is raised? You can simple subscribe to it when the application starts (in the Global.asax) and it will be raised for each user that signed in:

    public class MvcApplication : System.Web.HttpApplication
    {
        ...
    
        protected void Application_Start()
        {
            ...
    
            FederatedAuthentication.ServiceConfigurationCreated += (s, e) =>
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignedIn += new EventHandler(OnUserSignedIn);
            };
        }
    
        private void OnUserSignedIn(object sender, EventArgs e)
        {
            // Custom logic here.   
        }
    }
    

    The SignedIn event is the best way to detect a user sign in before the application continues. Take a look at the following diagram. Before redirecting back to a page, the SignedIn event is raised to allow you to detect an user sign in:

    Federated Authentication Module diagram

    Reference: http://msdn.microsoft.com/en-us/library/ee517293.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to detect if the current user is using a
I want to detect application name which is able to move into SD card
I want to be able to detect when the user has selected an option
I want to be able to detect and get notification, when the user is
Basically I want to write a script to be able to detect when the
I'm using LaTeX and BibTeX for an article, and I want to able to
I want to be able to take an image that i have already captured
I have a Cocoa application built using Garbage Collection with a main window. This
I am using cocos2d. I would like to be able to detect whether the
I have a table view that displays a list that I want the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.