我怎么知道登录与否

问题描述:

大家好
我创建了包含登录名和身份验证的网站,并且我想确定是否有人输入要重定向到登录页面的网址,并且当他成功登录后转到他输入了
的网址
我使用会话来了解某个登录名是否有效,但我希望获得最佳实践

Hi every one
I create web site contain login and authentication and I want to if someone type the url to redirected to login page and when he login successfully go the url he has typed

i use session to know if some one login or and it work but i ask for best practice

为了检查是否有人登录,请使用会话.为了重定向到请求的页面,您可以使用查询字符串.
In order to check if someone has logged in or not, use session. In order to redirect to the page which was requested for, you can use query string.


您可以在webconfig文件中使用以下内容

You can use the following in your webconfig file

<authentication mode="Forms">
    <forms name="AName" loginUrl="LoginPage.aspx" protection="All" timeout="20"/>
</authentication>



成功登录后,在登录页面中使用FormsAuthentication.RedirectFromLoginPage(username, False).



and in your login page use FormsAuthentication.RedirectFromLoginPage(username, False) once the login has been successfully carried out.