Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
protected void Page_Load(object sender, EventArgs e)
     {
          if(!Page.IsPostBack)
{
	Session["EmployeeName"]="Djay";
}
}

   protected void ddlProcess_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
               if(Session["EmployeeName"] !=null)
                {
                     // some code here
                }
                else
               {
                 // every time Debugger comes here after page post back
                }
            }
            catch (Exception)
            {
                Response.Redirect("/SitePages/SessionExpire.aspx", false);
            }
        }

What I have tried:

1. I used windows authentication (can't change to form authentication it's required )
2. and set <sessionstate mode="InProc" customprovider="DefaultSessionProvider" timeout="60"> in web config still face issue.</sessionstate>
Posted
Comments
njammy 2-Sep-16 11:00am    
Code looks fine, what is the value of Session["EmployeeName"] when the debugger hits the "else"?
Dj@y 2-Sep-16 11:02am    
it shows null in quick watch
njammy 2-Sep-16 11:05am    
Just a sanity check, create a brand new blank solution and one page which sets and gets a session var. Reply here with the results.
Dj@y 2-Sep-16 11:20am    
yes I created one another application use form authentication and set session values on page load within !ispostback and after post back it get null
njammy 2-Sep-16 11:29am    
Remove the customSessionProvider and use default see if it helps.

Check that your Web.config Authentication section looks similar:
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx"
timeout="2880"
cookieless="UseCookies" />
</authentication>

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