Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i m developing web application in asp.net with c#.
in which i m using master page with login and one order form.

login and order form is connected with master page.

i m creating session in master page. and redirect this session to booking form.

i m using web.config file in which session timout=20;

after successful login, i filled the booking form(which takes at least 2 minutes.)
when i clicked submit button. i m automatically redirect on login page.(because i code in master page that is as follows):
C#
if (Session["utype"] == null)
        {
           Response.Redirect("MainLogin.aspx");
       }
      if (Session["utype"].ToString() == "Admin")
      {
           AdminDiv.Visible = true;
           UserDiv.Visible = false;
         lblusername.Visible = true;
           lblusername.Text = Session["utype"].ToString();
      }
       if (Session["utype"].ToString() == "User")
       {
         AdminDiv.Visible = false;
          UserDiv.Visible = true;
         lblusername.Visible = true;
           lblusername.Text = Session["utype"].ToString();
      }

i can not understand that why it is automatically signed out.

i m also using <pages enableViewStateMac="false" />

in web.config.

pls help me .

thanks in advance.
Posted
Updated 5-Apr-11 23:56pm
v2
Comments
Ankur\m/ 6-Apr-11 6:08am    
Before redirecting the user to log-in page, assign Session["utype"] a proper value.
Rakesh From Patna 6-Apr-11 8:48am    
No, in login page you type the user id and password. if user id and password is correct then you assign the Session["utype"] then redirect the order form. you logout in order form button button then you then you type in button click event Session["utype"]="" or null; and redirect to login page.

1 solution

you remove the session timeout=20
in login page, you set the Session["utype"]=//you add type this code is add above of when you write response.redirect(orderform.aspx).

you also add the global.asax file and write smoething
void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        Session["utype"] = "";
        
    }


I hope work.
 
Share this answer
 

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