1

hii

how can i implement logout feature on my page so that user is redirected to a new page and is not allowed to view previous page.

Surbhi
  • 111
  • 3
  • 11
  • possible duplicate of [how to disable back button in browser when user logout in asp.net c#](http://stackoverflow.com/questions/589285/how-to-disable-back-button-in-browser-when-user-logout-in-asp-net-c) – Oded Nov 13 '10 at 09:37
  • 1
    This is typically done via the user session. There are numerous solutions for this in .Net - google is your friend. – mfloryan Nov 13 '10 at 09:38

4 Answers4

3
  if (SessionConfig.Current.UserType != null)
        Response.Redirect("~/Logout.aspx?UserType=" + SessionConfig.Current.UserType,false);
    else
        Response.Redirect("~/Default.aspx",false);

where sessionconfig is a session variable already declared.

 public static SessionConfig Current
        {
            get
            {
                SessionConfig session =
                  (SessionConfig)HttpContext.Current.Session["__SessionConfig__"];
                if (session == null)
                {
                    session = new SessionConfig();
                    HttpContext.Current.Session["__SessionConfig__"] = session;
                }
                return session;
            }
        }

Just put this in button click event and change to your home page in homepage.aspx . It will redirect the page and you cannot see the old page

Karthik Ratnam
  • 3,032
  • 2
  • 20
  • 25
1

Just add LogoutAction="RedirectToLoginPage" to the login control and it will solve your problem.

Hope this helps

Taryn
  • 242,637
  • 56
  • 362
  • 405
Ilan
  • 13
  • 1
0

take a look at ASP.net Login Controls
if you want the user to not be allowed to back to the previous page see this topic

Community
  • 1
  • 1
Mohamad Alhamoud
  • 4,881
  • 9
  • 33
  • 44
0

First of all, enable asp.net security permissions and set anonymous users access as Denied. then, use asp.net log-in control and set it up as you wish...

Dr TJ
  • 3,241
  • 2
  • 35
  • 51