Reputation: 1806
I have a login page and i am redirecting to another page on login. I am saving some data in Session, but unable to retrive the same in Page2.aspx.
I found some blogs and sites stating the same issue, but their solution won't work.
Here is my code from Page1.aspx
Session["Username"] = name; Response.Redirect("~/Page2.aspx",false);
In Page2.aspx
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] != null)
ClientScript.RegisterStartupScript(GetType(), "", "sendtoken();", true);
else
Response.Redirect("Page1.aspx");
}
Here the Session["Username"] is null
n the code in web.config is simple. I tried using
sessionState timeout="2"
n
mode="InProc" and "StateServer"
Upvotes: 2
Views: 2403
Reputation: 321
Old one, but i was having similar issues. Make sure your are not using web garden setup in your iis. In other words check that your Application pool does not contain more than one worker process (which is the default).
Application pools --> advanced settings --> Maximum worker Processes
Upvotes: 0
Reputation: 2012
The most common cause is cookies being disabled. You'll need to require cookies, or switch to a cookieless session model, which is a little harder to work with. refer this
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q316112
Upvotes: 1