How do you force the user to stay on a specific page of a website?

So here is what I am trying to achieve

When a user logs in and his password has expired, I redirect him to the change password screen. I would like the user to change their password before navigating to other links in the menu

I want to redirect back to that changepassword.aspx when it tries to leave, unless it changes its password

So how do I go about doing this? and more importantly, where?

Thanks for the help!

EDIT: I know we can use response.redirect, but it cannot be used in Unload operation

EDIT: ok i don't ask about this, i need help keeping the user on the page - how do i do it and what part of the page [loading, unloading, etc.] / p>

0


a source to share


6 answers


Please don't do this. This PITA UI is very annoying. Just complete your password and then don't get access unless they change it.

Don't treat your users like children (unless they really are children and maybe not even then)



Edit: made this a community response as I am just preaching without answering; -)

+6


a source


Explanation: Form Authentication in ASP.NET 2.0

"This module explains how forms authentication works in ASP.NET version 2.0. It explains how IIS and ASP.NET authentication works and explains the role and operation of the FormsAuthenticationModule class.



In web.config I have an authorization section saying

<authorization>
  <deny users="?"/>
  <allow users="*"/>
</authorization>


<location path="ChangePassword.aspx">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

      

+2


a source


  • Set the session to var if you need to change your password.
  • In every pageload check for that session, and if it exists (and they are not on the change password screen) redirect.
+1


a source


We used to use the master page on our site and in the event of this Page_Load event, we redirect the user to our changepassword.aspx page.

We also used (or abused, depending on your point of view) the Profile element for asp.net membership and simply set it to MustChangePassword. This means that when you log in, you can see if a MustChangePassword entry is set in their profile and redirected to the change password page. This certainly keeps them on the page.

People have the right to assume that sticking them on every page load is silly , but the overhead is tiny to check a single item in a user's profile, and you can at least force users who are currently logged in to change their password.

+1


a source


Check the box in the user's session indicating that he needs to change his password, then check this box from all of your other pages and redirect them to the change password page if necessary.

-1


a source


I would set the variable in my session and then in your check the Global.asax Application_BeginRequest event for the Session variable and redirect as needed.

-1


a source







All Articles