Last post Sep 02, 2016 07:19 PM by march11
Member
2 Points
11 Posts
Sep 01, 2016 01:27 PM|hanspam|LINK
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"); }
If the session expires I made a redirect to the index page where I define the session but I want to remain on the same page,
How do I show a authentication box to enter windows credentials? instead of going back to the first page and starting afresh
Contributor
2155 Points
2142 Posts
Sep 02, 2016 07:19 PM|march11|LINK
change this line of code to do what ever you want....
Response.Redirect("Index.aspx");
you could popup a login box to have the user re-authenticate.
There a few ways to deal with this
http://www.aspsnippets.com/Articles/Display-Session-Timeout-message-before-Session-expires-in-ASPNet.aspx
http://www.vijaykodali.com/Blog/post/2010/05/20/Alert-user-before-session-timeout.aspx
http://www.dotnetspark.com/links/17900-modal-popup-extendersession-timeout.aspx
Member
2 Points
11 Posts
Windows Authentication box when Session Expires
Sep 01, 2016 01:27 PM|hanspam|LINK
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
After this I have the other pages where I receive the data of my session like this
If the session expires I made a redirect to the index page where I define the session but I want to remain on the same page,
How do I show a authentication box to enter windows credentials? instead of going back to the first page and starting afresh
Contributor
2155 Points
2142 Posts
Re: Windows Authentication box when Session Expires
Sep 02, 2016 07:19 PM|march11|LINK
change this line of code to do what ever you want....
Response.Redirect("Index.aspx");
you could popup a login box to have the user re-authenticate.
There a few ways to deal with this
http://www.aspsnippets.com/Articles/Display-Session-Timeout-message-before-Session-expires-in-ASPNet.aspx
http://www.vijaykodali.com/Blog/post/2010/05/20/Alert-user-before-session-timeout.aspx
http://www.dotnetspark.com/links/17900-modal-popup-extendersession-timeout.aspx