表单身份验证重定向页面到登录页面而不是索引页面 [英] Form Authentication Redirect page to login page instead of index page

查看:357
本文介绍了表单身份验证重定向页面到登录页面而不是索引页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,



我在我的应用程序中提出了formuthertication,我在管理员用户的控制面板的索引页面中使用登录按钮。但是我的大多数页面都是公开的。



当我运行我的应用程序时



http:// localhost: 65300 / site / Public / frmLogin.aspx?ReturnUrl =%2fsite%2fPublic%2fIndex.aspx



Hello Friends,

i sue formauthertication in my application and i use login button in index page for control panel for admin user. but my most page are public.

when i run my application

http://localhost:65300/site/Public/frmLogin.aspx?ReturnUrl=%2fsite%2fPublic%2fIndex.aspx

<authentication mode="Forms">
     <forms loginUrl="~/Public/frmLogin.aspx" name="Egyan"   />
   </authentication>
   <authorization>
     <deny users="?"/>
   </authorization>





它直接进入登录页面,返回网址而非索引页面。





请帮忙我。



its directly goes to login page with return url instead of index page.


please help me.

推荐答案

请使用以下代码。这可能会有所帮助。



这里loginUrl是重定向网址,仅适用于那些需要身份验证的网页。另一方面,defaultUrl将允许用户访问普通页面。在我的代码中,根目录的admin文件夹中的.aspx页面将被要求登录,如果有人请求管理部分中的任何页面。



Kindly use the following code. It may help.

Here "loginUrl" is the redirect url that will work only for those pages which need authentication. Onthe other hand the "defaultUrl" will allow the user to visit the normal pages. Here in my code the .aspx pages inside the admin folder of the root directory will be asked to login, if anyone requests any page in admin section.

<system.web>
  <compilation debug="true" targetFramework="4.0" />
  <authentication mode="Forms">
    <forms timeout="30" loginUrl="login.aspx" defaultUrl="default.aspx" />
  </authentication>
</system.web>
<location path="admin">
  <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>


这篇关于表单身份验证重定向页面到登录页面而不是索引页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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