Context.clearerror() gives an error in Global.asax
I have added a Global.asax.cs in the App_code folder and this file looks like this
public class Global : System.Web.HttpApplication
{
private static ILog ms_logger = LogManager.GetLogger(typeof(Global));
private System.ComponentModel.IContainer components = null;
public Global()
{
InitializeComponent();
}
protected void Application_Start(object sender, EventArgs e)
{
log4net.Config.DOMConfigurator.Configure();
}
protected void Application_End(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
ms_logger.Error(ex.Message, ex);
if(Context!=null)
Context.ClearError();
ms_logger.Debug("Forwarding to ErrorPage.aspx");
Response.Redirect(AppConstants.ERROR_URL, true);
}
protected void Session_Start(object sender, EventArgs e)
{
ms_logger.Debug("Starting new session");
}
protected void Session_End(object sender, EventArgs e)
{
Response.Redirect(AppConstants.LOGOUT_URL, true);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
}
And in the web.config file i have added the session state as inpoc and it looks like this
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="1">
</sessionState>
wantedly i have configured timeout to 1 min.
after one min i am getting error in global.asax.cs near the context.clearall but i added if context!=null and it was fine now i am getting near Response.Redirect(AppConstants.ERROR_URL, true),
but the same code worked in the 1.1 application and when session times out it takes me to logout page but in 2.0 its not happening remaining in the same page after session timeout.
Can anyone help me out to solve this problem or tell me an alternate solution to take to logout page after session expires.
__________________
Regards,
P.Madhusudhana Rao
|