When i implement the following code in my Global.asax.cs in the session timeout procedure, It prompts me an error...

HttpContext.Current.Response.Redirect("login.aspx");

What will be the problem?

Note: I want to forward the user to login page when the session is timeout.So i used this. Correct me if i am wrong in my procedure.

Recommended Answers

All 4 Replies

Please elaborate on "prompts me an error"--I presume this was an unhandled exception... post the type of exception and the actual text of the message.

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
            Session.Timeout = 2;

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.
            HttpContext.Current.Response.Redirect("login.aspx",true);

        }

these are my code

And it provides NullReferenceException was hanndled by user code and it provides this exception on ";" at session_end event...

Sorry for late reply...

Can u help me out????

If I remember correctly, the session end event doesn't have an HTTP context because it's not initiated by a request; it happens on the server when it decides the session is over, either timed out or abandoned.

So How can i implement it gusano79... Because I am a newbie to web apps development.Can you give me a clear explanation please?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.