UnlnvlslblE
Limp Gawd
- Joined
- Jan 24, 2006
- Messages
- 272
Hey guys. I've been trying to figure this whole thing out for weeks now and still have had no luck. I'm not brand new to programming but I'm not a seasoned vet either. I'm working on a team developing a webapp with ASP.NET 2.0 with C#. I have this running on an IIS box which is also running MS SQL server 2005. I have the application's web.config setup to use a custom SQL server database to store the session information.
When a client logs onto the application, a session is started and the browser is given a cookie. The SQL session table is updated with this info as well. I have verified the cookie is created and the table is updated. The problem arises when a user clicks the home button in our application which in turn redirects them either to a welcome page or an admin page based on a session containing an access level. On the initial login the user gets redirected just fine however after being logged in for a minute, if they hit the home button it will throw an exception that the session is null.
Does anyone have any idea of what's going on or how to get this running? I'm not really sure what to do now; I'm really stuck here. Here are a couple code snippets to give you an idea of how things are setup.
From the web.config:
<sessionState
mode="SQLServer"
cookieless="false"
sqlConnectionString="connectionString"
allowCustomSqlDatabase="true"
>
</sessionState>
From the login web form:
protected void LogonUser(object sender, EventArgs e)
{
//Read in the username
String userName = username.Text;
//If the user is authenticated
if (authenticateUser(userName, hashPassword(password.Text), schoolid.Text))
{
//Set a session with their accesslevel
Session["accesslevel"] = getAccessLevel(userName);
FormsAuthentication.RedirectFromLoginPage(userName, false);
}
//If the user was not authenticated
else
{
//Let the user know something went wrong
username.Text = "Invalid username";
schoolid.Text = "Invalid school id";
}
}
From the welcome page (throws a null exception after the user is logged in and clicks home):
if (Session["accesslevel"].ToString().Equals("0"))
Response.Redirect("admin.aspx");
Thanks for reading and thanks for any insight. I'm really stuck here. Thanks!
When a client logs onto the application, a session is started and the browser is given a cookie. The SQL session table is updated with this info as well. I have verified the cookie is created and the table is updated. The problem arises when a user clicks the home button in our application which in turn redirects them either to a welcome page or an admin page based on a session containing an access level. On the initial login the user gets redirected just fine however after being logged in for a minute, if they hit the home button it will throw an exception that the session is null.
Does anyone have any idea of what's going on or how to get this running? I'm not really sure what to do now; I'm really stuck here. Here are a couple code snippets to give you an idea of how things are setup.
From the web.config:
<sessionState
mode="SQLServer"
cookieless="false"
sqlConnectionString="connectionString"
allowCustomSqlDatabase="true"
>
</sessionState>
From the login web form:
protected void LogonUser(object sender, EventArgs e)
{
//Read in the username
String userName = username.Text;
//If the user is authenticated
if (authenticateUser(userName, hashPassword(password.Text), schoolid.Text))
{
//Set a session with their accesslevel
Session["accesslevel"] = getAccessLevel(userName);
FormsAuthentication.RedirectFromLoginPage(userName, false);
}
//If the user was not authenticated
else
{
//Let the user know something went wrong
username.Text = "Invalid username";
schoolid.Text = "Invalid school id";
}
}
From the welcome page (throws a null exception after the user is logged in and clicks home):
if (Session["accesslevel"].ToString().Equals("0"))
Response.Redirect("admin.aspx");
Thanks for reading and thanks for any insight. I'm really stuck here. Thanks!