Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my WebSite i am using 15 webforms ..

1.Default.aspx
2.Welcome.aspx
3.Application.aspx
4.apply.aspx
All pages have Logout button.


once i click the logout button page redirect to My HomePage(Default.aspx)

my problem is
once i click the logout button. i am trying to open directly 2,3 ,4...15 pages . how the page is automatically Redirected to HomePage(Default.aspx)


C#
protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Session.RemoveAll();
            Session.Abandon();
            Response.Redirect("Default.aspx");
        }


What I have tried:

protected void btnLogout_Click(object sender, EventArgs e)
{
Session.Clear();
Session.RemoveAll();
Session.Abandon();
Response.Redirect("Default.aspx");
}
Posted
Updated 24-May-16 23:56pm
v4
Comments
OriginalGriff 25-May-16 4:00am    
And?
What have you tried?
Where are you stuck?
What help do you need?

All you have done is show your logout button - we have no idea what your problem is or if that code works for you.
Use the "Improve question" widget to edit your question and provide better information.
Member 11652153 25-May-16 4:17am    
Please Check once again my question..
OriginalGriff 25-May-16 4:27am    
That still tells us nothing useful!
If they are redirecting, than that is what you want isn't it?

Remember that we can't see your screen, access your HDD, or read your mind. We only ever get exactly what you type to work with. So when you tell us nothing *because you already know it* we can't answer your question! Pretend you are explaining the problem to your mother on the phone - she could see exactly as much as we can! :laugh:
F-ES Sitecore 25-May-16 4:58am    
It depends on how you know someone is logged in which you haven't said. If you are storing the fact that they are logged in in the Session then create a BeginRequest event in global.asax and check the Session to see if they are logged in and if they aren't redirect to the home page

http://www.dotnetperls.com/global-asax

1 solution

Once you call 'Session.Abandon()', all your session variable get expired and you should re-direct to login page only.
if you try to open any page directly (without login) you may check for any session variable value, if it is NULL you can just redirect to login page (default.aspx in your case).
 
Share this answer
 
Comments
Member 11652153 25-May-16 6:15am    
Thanks you Bro.
koolprasad2003 25-May-16 6:18am    
Glad to help you.
- Accept as solution if it resolve your issue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900