开发者

How to redirect the user to password recovery page with forms authentication

I am a beginner of asp.net..I currently have a login page with forgot password link button on the bottom of the screen. I am also using forms authentication to prevent an unauthorized user from accessing the other pages. The authentication seems to be working fine except for one thing. It prevents the user from accessing the password recovery page once the user click on the link button. How do I allow all users access to the login/password pages and also prevent them from viewing the other pages if they are not authenticated?

The code below is to prevent from other anonymous view other pages without access. But i got no idea on how to allow them to access password recovery page...

<authentication mode="Forms">
  <forms lo开发者_C百科ginUrl="/Presentation/Display/Login.aspx" name=".ASPNETAUTH" protection="All" path="/" timeout="120" cookieless="UseDeviceProfile" slidingExpiration="true"/>
</authentication>
<!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
<authorization>
  <deny users="?"/>
</authorization>


You need to use the <location> element to apply settings to a specific path, then add an <allow /> for non-logged-in users.

For example:

<location path="PasswordRecovery.aspx">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>


<location path="Presentation/Display/PasswordRecovery.aspx">
  <system.web>
    <authorization>
      <allow users="?"/>
    </authorization>
  </system.web>
</location>

This allows anonymous users to view your password recovery page. You might want to do the same for the directory where your CSS and/or image resources are stored, in case they are required by your login page and/or your recovery page.


Use Location:

<location path="passwordrecovery.aspx">
   <system.web>

      <authorization>
          <allow users="*"/>
      </authorization>
   </system.web>
</location>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜