none
Windows Authentication box when Session Expires RRS feed

  • Question

  • Im working on a project with Windows Authentication and Session States.

    I have this code where i get the username, save it in a session and also in a label

    if (!IsPostBack) { using (var context = new PrincipalContext(ContextType.Domain)) { var usr = UserPrincipal.FindByIdentity(context, User.Identity.Name); if (usr != null) Session["Application1_Data"] = usr.DisplayName; lbl_Login.Text = usr.DisplayName; } } After this I have the other pages where i receive the data of my session like this if (Session["Application1_Data"] != null) { lbl_Login.Text = Session["Application1_Data"].ToString(); } else { Response.Redirect("Index.aspx"); }

    Im working on a project with Windows Authentication and Session States.

    I have this code where i get the username, save it in a session and also in a label

    Wednesday, August 31, 2016 1:49 PM

All replies

  • Hi Hanspam,

    According to your description and sample code, are you developing ASP.Net project? If so, since this is the forum to discuss questions and feedback for Word for Developers, I suggest that you could post your question on ASP.Net forum

    http://forums.asp.net/

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, 
    and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. 

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Thursday, September 8, 2016 1:20 AM
    • Marked as answer by David_JunFeng Thursday, September 8, 2016 1:20 AM
    • Unmarked as answer by David_JunFeng Friday, September 9, 2016 1:48 AM
    Thursday, September 1, 2016 2:14 AM
  • You are right, I didn't notice that! Thanks

    Thursday, September 1, 2016 1:16 PM