且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET中的Session.Abandon问题

更新时间:2023-02-15 22:58:26

放弃会话时您还在安全区域内吗?服务器可能正在尝试交付用户不再有权接收的页面.

让注销按钮执行Response.Redirect("PageOutsideSecureArea.aspx"),该页面放弃您的会话.然后,该页面可以自动重定向到您的默认页面,或者显示一个礼貌的您已经注销"消息和指向主页的链接(IMO是更好的设计.)
Are you still within your secured area when you abandon your session? It might be that the server is trying to deliver a page that the user no longer has permission to receive.

Have the log out button execute a Response.Redirect("PageOutsideSecureArea.aspx"), with that page abandoning your session. The page can then either automatically redirect to your default page, or have a polite "You have been logged out" message and a link to the home page (which, IMO, is better design.)


您可以尝试使用类似的方法:

You can try something like this instead:

Session.Contents.Remove("yoursessionid");
Response.Redirect("http://mysite.com/Default.aspx")



您可能会想出一种方法来正确解析路径(在对Response.Redirect的调用中),以便该路径可同时在您的开发箱和已部署的网站上使用



You''ll probably want to figure out a way to properly resolve the path (in the call to Response.Redirect) so that it works on both your dev box and your deployed web site