How to Redirect to "Home Page", when logout from the site? [Resolved]

Posted by Iluvdotnetfunda under ASP.NET on 2/27/2012 | Points: 10 | Views : 13763 | Status : [Member] | Replies : 6
Hi Friends,

Special Day.

when someone click on the logout page, then page must redirect to home page.
Please help me.

Thanks&Regards
iluvdotnetfunda




Responses

Posted by: Ppathi on: 2/27/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

If u use link button and state has maintained with session. In Code behind u should write this code under button click event like

remove your store session values like
Session.Remove(_UserName);
Session.Abandon();
Session.Clear();

Response.Redirect("YOUR LOGIN PAGE URL")

ex: Response.Redirect("/Login.asp");

If u use anchor tag. Sample code is

<a href="/login.aspx">LOGOUT</a>




Thanks & Regards,
Pasupathi G
No Pain No Gain

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 2/27/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Yes PPathi is right,
either you can write your code in global.asax onSessionEnd event:

protected void Session_End()

{
Response.Redirect("login_page.aspx");
}


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kuki123 on: 2/27/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
protected void Button2_Click(object sender, EventArgs e)
{
response.redirect(""home_page.aspx);
}

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 2/27/2012 [Member] Silver | Points: 50

Up
0
Down

Resolved

Clear the Session value if any otherwise , simply redirect to the desired page using Response.Redirect("HomePage.aspx")
or Server.Transfer("HomePage.aspx").

In case you are using Session, then in all other pages check the Session variable value is null or not . It it is found to be null then redirect to home page.
Hope this helps.

Thanks,
Sanjay

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pradeepkumar417 on: 2/28/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Try this below code

protected void Logout(object sender, EventArgs e) 

{
Session.Abandon();
Response.Redirect("home.aspx",true);
}


Thanks & Regards,
Software Engineer,
Pradeep Kumar

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 2/28/2012 [Member] Starter | Points: 25

Up
0
Down
Hello Friends,

Thanks for your Response.

I got the solution.

Thanks&Regards
iluvdotnetfunda

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response