How to get the UserID and Email while SSO Authentication? RRS feed

  • Question

  • User-1858220497 posted


    I have two websites www.site1.com and www.site2.com. I implemented SSO by setting the same Machine key for the both websites. Everything is OK and works fine, But I cannot get the UserID and Email truly in both websites:

    Suppose that user1 from the site1 logs in, because of implementing SSO the user would be authenticated in the site2 too. In this situation the following code works fine in site1:

    MembershipUser muser = Membership.GetUser();

    Label1.Text = muser.Email + "<br/>" + muser.ProviderUserKey.ToString() ;


    But this code gets the error “object reference not set to an instance of…” in the site2.com

    Each website has a separate database and both of them uses asp.net membership provider and form authentication.

    So could you please tell me how can I get the UserId and User Email in the site2.com as I discussed?  


    Wednesday, February 25, 2015 2:57 PM


  • User1779161005 posted

    A shared cookie isn't really SSO. I think you'd want to consider a proper SSO solution, but that involves setting up a SSO server. Look into OpenID Connect as the modern protocol to support this. IdentityServer3 is an open source implementation done in .NET:


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 27, 2015 9:45 AM

All replies