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?
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?