views:

58

answers:

1

Hi, I new to .aspx and now the thing is since i am doing a web enabled project, I have this login from an user. I drag dropped the login template and then used the

Session["Authentication"] = username.Tostring();

to store the current logged user's info and so. Now i even used a hyperlink "Logout" at the top right corner and then made it transfer to Login page. ( If this is wrong way of transfering Please Let me know, I am Learning all by internet)..

Now if on running the web , i can easily login , but when i logout through hyper link "logout" it will take me to the Login page again, but if i press the back button of the browser it again transfers the control to the data page and i can again perform the data operation's.

I used this

Session["Authenticate"] = null

at the page load of the login page so that only at the login button click the user can enter again by

Session["Authenticate"] = username.Tostring();

Then i used a check at each page load of the data pages

if(Session[Authentiacte"] == null)
     Server.Tranfer("LoginPage.aspx");

This didnt solve my problem, Please can anyone give a hint or a link or a tip to improve my way of logout? I strated this project without any knowledge of the .net or aspx and i am still learning everything, please bare my doubts thankx in advance..

+2  A: 
HttpContext.Current.Session.Clear();
HttpContext.Current.Session.Abandon();
HttpContext.Current.User = null;
System.Web.Security.FormsAuthentication.SignOut(); // if forms auth is used
abatishchev
Where should use this ? i mean on the login page? Becuase my logout is a hyperlink
Nagaraj Tantri
@Nagaraj: Create a `Logout.aspx` (where your link should lead) and add this calls to `Page_Load(object,EventArgs)` or `OnLoad()`
abatishchev