且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET重定向未经授权的用户默认/登录页面

更新时间:2023-12-01 14:43:22

默认情况下窗体身份验证用户的网页重定向名为的login.aspx 时,他/她试图访问受限制的资源的人,他/她目前还没有权限。所以,如果你没有在的login.aspx 未找到资源错误( HTTP 404 )将被抛出。 为了克服这个创建的login.aspx 页面或告诉asp.net使用另一个页面(yourloginpage.aspx)作为登录页面。做你应该在&LT定义它后者;形式GT; 在你的web.config的建议通过 sathishkumar印标记

By default forms authentication redirects the user to a page with the name login.aspx when he/she tries to access a restricted resource to whom he/she currently has no permission. So if you don't have the login.aspx the resource not found error(HTTP 404) will be thrown. To overcome this create the login.aspx page or tell asp.net to use another page(yourloginpage.aspx) as the login page. To do the latter you should define it in the <forms> tag in your web.config as suggested by sathishkumar indian

  <authentication mode="Forms">
    <forms loginUrl="yourloginPage.aspx" />
 </authentication>