Loing控件登录后跳转的问题
已设置好HR 目录的权限,为何登录后不跳转到~/HR/Default2.aspx页面,
我输入错误用户名或者密码会提示“您的登录尝试不成功。请重试。”,便我输入对了也不行啊
根目录Web.config部分内容
<system.web>
<authentication mode= "Forms ">
<forms loginUrl= "~\validate\validate.aspx "
protection= "All " timeout= "30 "
name= "AppNameCookie "
path= "/FormsAuth "
requireSSL= "false "
slidingExpiration= "true "
defaultUrl= "~/HR/Default2.aspx "
cookieless= "UseCookies "
enableCrossAppRedirects= "false "/>
</authentication>
<!--
<authorization>
<deny users= "? " />
</authorization>
<membership defaultProvider= "SqlMembershipProvider " userIsOnlineTimeWindow= "15 ">
<providers>
<clear/>
<add name= "SqlMembershipProvider " type= "System.Web.Security.SqlMembershipProvider " connectionStringName= "MRPConnectionString " applicationName= "/ " enablePasswordRetrieval= "false " enablePasswordReset= "true " requiresQuestionAndAnswer= "true " requiresUniqueEmail= "false " passwordFormat= "Hashed " maxInvalidPasswordAttempts= "5 " minRequiredPasswordLength= "5 " minRequiredNonalphanumericCharacters= "0 " passwordAttemptWindow= "10 " passwordStrengthRegularExpression= " "/>
</providers>
</membership>
<roleManager enabled= "true ">
<providers>
<remove name= "AspNetSqlRoleProvider "/>
<add name= "AspNetSqlRoleProvider " connectionStringName= "MRPConnectionString " applicationName= "/ " type= "System.Web.Security.SqlRoleProvider "/>
</providers>
</roleManager>
------解决方案--------------------
这与webconfig没有什么关系.
1.如果你想注册后直接跳转页面,直接打
Response.Redirect( " ")//引号中为你要跳转的页面如mainFrame.aspx
2.如果你想服务器给你提示后再跳转页面就打
Response.Write( " <script> alert( '登陆成功! ') </script> ");
Response.Write( " <script> window.location= ' ' </script> ");//引号中为你要跳转的页面如mainFrame.aspx
[解决办法]
<authorization>
<deny users= "? " />
</authorization>
有没有问题
[解决办法]
因为你是阻止匿名用户来登陆或访问不该访问的页面,这个时候想让登陆的用户访问可以访问的页面就要创建一个用户角色票在登陆是写上:
FormsAuthentication.SetAuthCookie(LoginID.ToString(),true);
应该就没问题了,但是这个时候次登陆用户可以访问所有页面了,所以还要加一些权限的限制,
这个可以在页面第一次加载是进行判断用户的权限来限制
[解决办法]
你可以直接访问 默认页面,
这时因为没有权限所以跳到登录窗口,
登录成功后再用
FormsAuthentication.SetAuthCookie(LoginID.ToString(),false);
来跳转到指默认页面