ASP.NET登录和表单身份验证 [英] ASP.NET Login and Form Authentication

查看:115
本文介绍了ASP.NET登录和表单身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Web应用程序项目,我想使用表单身份验证和授权来添加安全登录功能.我有一些安全页面和一些非安全页面.我希望登录提示应始终出现在安全页面上,而不是非安全项目上.另外,当我在浏览器上单击返回"按钮时,如果不登录就不能进入我的帐户.登录前需要询问我.如果移动到不安全的物品,也应该要求我退出,这也很好.首先.
提前谢谢.


-Sameer B

I have an ASP.NET web application project, I want to add Secured Login Functionality using Form Authentication and Authorization. I have some secured pages and some nonsecured pages. I want login prompt should always come for secured pages and not for nonsecure items. Also when I hit "BACK" button on browser and should not be able to go in my account without logging in. I need to be asked before logging in. Also it would be great if I move to nonsecure items it should ask me to logout first.
Thanks in advance.


-- Sameer B

推荐答案

设置身份验证以在您的Webconfig文件中形成身份验证
1.不要在webconfig文件中指定登录页面
2.对于页面加载或初始化事件中的安全页面,请检查 User.Identity.IsAuthenticated
3.如果用户未通过身份验证,则重定向到登录页面
4.您可能会在不安全页面上使用相同的属性,并且如果用户已经通过身份验证,则可以提示用户注销或首先将用户重定向到注销页面

希望对您有帮助
set authentication to form authentication in your webconfig file
1.do not specify the login page in webconfig file
2.for your secure page in page load or initialize event check for User.Identity.IsAuthenticated
3.and if user is not authenticated redirect to login page
4.you might use the same property on insecure page and if user is already authenticated then you can prompt user for logout or redirect user first to logout page

hope this will help you


这篇关于ASP.NET登录和表单身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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