使用c#登录asp.net后恢复原始页面 [英] Revert back to original page after login in asp.net using c#

查看:88
本文介绍了使用c#登录asp.net后恢复原始页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设用户正在打开课程页面以查看我想要查看的课程信息,如果用户登录,则用户可以访问页面,否则通过Response.Redirect(Login.aspx)进入登录页面;首先登录然后恢复到登录页面的页面,使用这个

Response.Redirect(Request.Cookies [path]。Value.ToString());



但它不起作用它会给出错误

对象引用未设置为对象的实例。



告诉我一些其他的方法来做这个或挑出错误plz

suppose the user is opening the course page to see course info i want to chck that if the user is login then user can access page else it goes to loginpage through " Response.Redirect("Login.aspx");" first login then revert to the page from where it goes to login page by using this
Response.Redirect(Request.Cookies["path"].Value.ToString());

but it is not working it is giving the error that
Object reference not set to an instance of an object.

Tell me some other way to do this or pick out the error plz

推荐答案

如果你这样做的正确方法 - 使用会员资格 - 然后所有这一切都是自动的,发生在幕后。如果用户尝试在未登录的情况下打开页面,则会自动将其重定向到登录页面,然后在成功登录时返回到他想要的位置。



这很容易做到: MSDN会员资格简介 [ ^ ]将引导您完成整个过程。
If you do this the proper way - using Membership - then all of that is automatic and happens behind the scenes. If the user tries to open a page without logging in, he is auto redirected to the login page, then back where he wanted to g when he logs in successfully.

It''s easy to do: MSDN Introduction to Membership[^] will walk you though the whole process.


这篇关于使用c#登录asp.net后恢复原始页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆