Session Variables Not Saved

M

Mike Lee

Hey All,
Using C# with ASP.NET 1.1 and I've noticed an issue on my system
running pages that save data to the session object. I've got a login
page that after you login and are verified it will store the username
to the session then do a redirect to the default page:

private void btnLogin_Click(object sender, System.EventArgs e)
{
WebValidationWebService.WebValidation wv = new
WebValidationWebService.WebValidation();
bool valid = wv.CheckLogin(this.txtUserName.Text,
this.txtPassword.Text);
// they are using a valid login
if(valid)
{

this.SetUserName(this.txtUserName.Text);
Response.Redirect("default.aspx", true);
}
}

//located in the base class of the form
protected virtual void SetUserName(string UserName)
{//SESSIONKEY_USERNAME is a string const
Session.Add(SESSIONKEY_USERNAME, UserName);
}

seems then I click login it validates properly and redirects me, the
problem is when I hit the default page the username in the session is
gone. I've noticed the session_start event does get fired multiple
times but I cannot figure out why. The only way I can get sessions to
work is change the web.config to cookieless:

<authentication mode="Forms">
<forms name="TradeEntryCookie" loginUrl="login.aspx" protection="All"
path="/" />
</authentication>

.. . . .


<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="true"
timeout="20"
/>

Any Suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top