60分求谁能够教会我forms认证
感觉那个东西有点麻烦,可能是因为我是新手的问题,还不是太懂,比如说现在有2个文本框,一个是输入帐号,另外一个是密码,点登陆以后,froms 认证怎么记录这2个值?还要用session吗?怎么读?还有怎么在webconfig里设置??还有,登陆进去以后页面怎么判断你是否符合身份?感觉很难啊
[解决办法]
<!-- 通过 <authentication> 节可以配置 ASP.NET 使用的 安全身份验证模式, 以标识传入的用户。 --> <authorization> <allow users="*"/> </authorization> <authentication mode="Forms"> <forms loginUrl="~/Logon.aspx" protection="All" timeout="30" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/> </authentication> <!-- 如果在执行请求的过程中出现未处理的错误, 则通过 <customErrors> 节可以配置相应的处理步骤。具体说来, 开发人员通过该节可以配置 要显示的 html 错误页 以代替错误堆栈跟踪。 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> </system.web> <location path="admin"><!--这里是要登录才能操作的页面文件夹名字--> <system.web> <authorization> <deny users="?"/> <allow users="*"/> </authorization> </system.web> </location></configuration>
[解决办法]
获取当前用户名
用
string name=Page.User.Identity.Name
[解决办法]
http://blog.csdn.net/eyu777/archive/2008/05/27/2487311.aspx
给你参考下吧 Forms验证,多角色,多登录页
[解决办法]
看我的LZ
这个是webconfig
<authentication mode="Forms"> <forms name=".Member" loginUrl="Manage/Login.aspx" protection="All" timeout="20"/> </authentication> <!-- 如果在执行请求的过程中出现未处理的错误, 则通过 <customErrors> 节可以配置相应的处理步骤。具体说来, 开发人员通过该节可以配置 要显示的 html 错误页 以代替错误堆栈跟踪。 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> <customErrors mode="Off" defaultRedirect="Error.aspx"> </customErrors> </system.web> <location path="Manage"> <system.web> <authorization> <deny users="?"/> <allow users="*"/> </authorization> </system.web> </location>