会话销毁后如何重定向用户上次访问的Web表单 [英] How to redirect user last accessed web form after session destroyed
本文介绍了会话销毁后如何重定向用户上次访问的Web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友.....
我们正在使用asp.net创建一个网站.问题在于,如果由于时间过期而导致会话被破坏,它将重定向到登录表单,登录后用户应从被破坏的会话中重定向到上次访问的Web表单.
例如,用户访问default3.aspx,然后破坏会话.默认情况下,登录后他将移至登录页面.aspx应该处于打开状态.
我想您了解我的问题.谢谢.........
Randeep Chauhan
hi friends.....
we are making a website using asp.net.Problem is that if session destroyed due to time expire .It redirect to login form and after login user should redirect to last access web form from the session destroyed.
for example user access default3.aspx and then session destroyed.he move to login page after login by default3.aspx should be open.
I think you understand my problem.Thanks.........
Randeep Chauhan
推荐答案
如果会话被破坏,最好的方法是使用cookie-将当前位置存储在cookie中并返回到它. br/>
或者,您可以使用 FormsAuthentication.RedirectFromLoginPage [
If the session is destroyed, the best way to do it is to use cookies - store a current location in the cookie and go back to it.
Alternatively, you could use the FormsAuthentication.RedirectFromLoginPage[^] method which should take him back where he was.
一个解决方案可能是这样:
您需要一点来查看每个页面的转换,因此带有ContentPlaceHolder
的Master Page
是一个不错的选择.
在内容占位符的OnLoad
事件中,您可以通过以下命令访问当前页面名称:
(((System.Web.UI.Control)(sender)).Page).Request.Path
将其保存在当前用户的永久位置(如数据库)中.
用户每次登录到您的Web应用程序时,都会检索其上次访问的位置并将其重新引导到该位置.
希望对您有所帮助.
One solution can be this :
You need a point to see every page transitions so aMaster Page
with aContentPlaceHolder
is a good choice.
In content place holder''s ,OnLoad
event you can access to current page name via this :
(((System.Web.UI.Control)(sender)).Page).Request.Path
Save it in a permanent location (like database) for current user.
And every time that the user logs into your web application retrieve his/her last visited location and redired him/her to that location.
Hope it helps.
这篇关于会话销毁后如何重定向用户上次访问的Web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文