Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Ca any one help me on
"redirect to logout page when session expire" in asp.net ?
Posted

try this.. :)

C#
if (Session["sessionName"] == "" && Session["sessionName"] == null)
            {

                Response.Redirect("YourPage.aspx"); //PageName.aspx
            }
 
Share this answer
 
Comments
Mukesh Ghosh 13-Jun-14 5:41am    
Response.Redirect does not work
Put Some variable in the session like logged user name for example after user loin.
In every page except login page you can check for this session value null or not. if this value is null you can re direct user to login page ( or logout page as you wanted but normally in session expiration user will direct to login page)

if you using Form authentication, set login url in your web config as below
HTML
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login.aspx" defaultUrl="~/Default.aspx" timeout="20">
  </forms>
</authentication>
 
Share this answer
 
v2

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