Thanks Nicholas.
I use "Form Auth" to login. and I still need to store some info in the
Session["xx"] for other pages. How to deal the case: if session expire.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 378: StateIndex["ON"] = 7;
Line 379:
Line 380: if (Session["Lever"] == null)
Line 381: {
Line 382: Response.Redirect("login.aspx");
Source File: c:\project\Test\admin.aspx.cs Line: 380
message news:el63g0jmDHA.1740@TK2MSFTNGP12.phx.gbl...
LL,
There will always be a session object available to you (or at least,
there should be). The best way to do this would be to set up the web.config
file to deny any unauthorized users. Basically, you place a <deny
users="?"> element in the <authorization> section and it will redirect
unauthorized users to the login page that you specify.
Check out the section of the .NET framework titled "Forms Authentication
Provider", located at (watch for line wrap):