Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Haii,

Am Getting an Error as Follows..
Server Error in '/' Application.
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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   TRANSACTION_frmStore.Page_Load(Object sender, EventArgs e) +58
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

This is happening When the Session is Expired. Code to handle the error is there in global.asax.
Locally the Application is running Fine bt after hosting this error is happening.. ie it is not redirected to Login.aspx.

Why it is happening so..

Thanks in advance..
Posted
Updated 5-Jul-12 20:04pm
v2

1 solution

Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null. As you already pointed, this is happening when the session expires. If so, some code is trying to access a null value and hence the error.

Now, if you want to redirect person to login page after timeout, you need to set the same timeout (or 1 minute less) for forms authentication. Automatically, your application will be directed to login page once timeout happens.


This is happening When the Session is Expired. Code to handle the error is there in global.asax.
Locally the Application is running Fine bt after hosting this error is happening.. ie it is not redirected to Login.aspx.

It might be that code is hitting the method but there is some error in it, like some access permission issue if logging is there. (Application_Error code would have helped here!)
 
Share this answer
 
Comments
anish.karunakaran 6-Jul-12 2:30am    
bt it doesn't seems an error in the event..
simply the code in it is..
void Application_Error(object sender, EventArgs e)
{

Exception objErr = Server.GetLastError().GetBaseException();

string ssss = objErr.TargetSite.ToString();
string help = objErr.HelpLink;
string err = "<!---" + "Error Caught in Application_Error event <br> " +
"Error in: <br> Error Message:" + objErr.Message.ToString() +
" <br> Stack Trace:" + objErr.StackTrace.ToString()
+ "-->";
try
{
Session["Erroronly"] = err.ToString();

Response.Redirect("~/Login.aspx?TimeOut=Yes");
}
catch
{

}
}
Sandeep Mewara 6-Jul-12 2:56am    
Do a simple test if possible, comment all and just put 'Response.Redirect("http://www.google.com");' in your Application_Error

See what happens.
anish.karunakaran 6-Jul-12 5:22am    
I tried that .Same Effect.That event is not fired. how can resolve this..Pls help. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900