How to rewrite SessionID?

by dee 17. January 2008 01:03

The only possibility to make that trick it is to change "ASP.NET_SessionId" cookie before ASP.NET has loaded session state. It can be achieved by handling PostMapRequestHandler application event. For example:

 

void Application_PostMapRequestHandler(object sender, EventArgs e)
{
    string aspNetSessionName = "ASP.NET_SessionId";
    if (Request.Cookies[aspNetSessionName] != null)
    {
        Request.Cookies[aspNetSessionName].Value = "new session ID";
    }
    else
    {
        HttpCookie sessionIDCookie = new HttpCookie(aspNetSessionName, "new session ID");
        Request.Cookies.Add(sessionIDCookie);
    }
}

ASP.Net Events issue

by dee 7. January 2008 18:41

ASP.NET is not able to load types of custom web events if they are placed under App_Code directory. Most probably it happens because Type.GetType() method is used, which cannot load ASP.NET 2.0 App_Code types since they are available during execution time only. We should use System.Web.Compilation.BuildManager.GetType() method instead. For now the solution is only to separate needed type to another assembly and point configuration to it.

Session object in Session_End event

by dee 3. January 2008 14:59

Trying to use HttpContext.Current.Session in Session_End event of Global.asax will result in NullRefenceException. Use just Session (without HttpContext.Current) object instead.

Debugger.Break() and IIS issue

by dee 2. January 2008 18:01

For debugging it is very useful to use followed code in Global.asax:

void Application_Error(object sender, EventArgs e)
{
    System.Diagnostics.Debugger.Break();
}

But if you deploy it on IIS then in case of unhandled exception the followed dialog window will be shown for current logged on user:

The solution is to remove System.Diagnostics.Debugger.Break(); from code before deploying.

Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen