Cookie add in the Global.asax warning in application log

Posted by Ioxp on Stack Overflow See other posts from Stack Overflow or by Ioxp
Published on 2010-05-25T16:30:17Z Indexed on 2010/05/25 16:31 UTC
Read the original article Hit count: 297

Filed under:
|
|
|

In my Global.ASAX file i have the following:

System.Web.HttpCookie isAccess = new System.Web.HttpCookie("IsAccess");
isAccess.Expires = DateTime.Now.AddDays(-1);
isAccess.Value = "";
System.Web.HttpContext.Current.Response.Cookies.Add(isAccess);

So every time this method this is logged in the application events as a warning:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 5/25/2010 12:23:20 PM 
Event time (UTC): 5/25/2010 4:23:20 PM 
Event ID: c515e27a28474eab8d99720c3f5a8e90 
Event sequence: 4148 
Event occurrence: 332 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/2100509645/Root-1-129192259222289896 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: <PathRemoved>\www\ 
    Machine name: TIPPER 

Process information: 
    Process ID: 6936 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: NullReferenceException 
    Exception message: Object reference not set to an instance of an object. 

Request information: 
    Request URL:  
    Request path:  
    User host address:  
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 7 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    at ASP.global_asax.Session_End(Object sender, EventArgs e) in <PathRemoved>\Global.asax:line 113

Any idea why this code would cause this error?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET