0

I randomly get this error and would like to know the best way to debug this and what it means.

MESSAGE: Object reference not set to an instance of an object.
SOURCE: POL
FORM: __VIEWSTATE={{LONG STRING OF TEXT HERE}}
URL: /SourceIt.aspx
QUERYSTRING:
TARGETSITE: Void Page_Load(System.Object, System.EventArgs)
STACKTRACE: at POL.PreDischargeEducation.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

EDIT: This error also randomly happened. Could updating .NET or something server side have been the cause of this?

EDIT:

protected void Page_Load( object sender, EventArgs e ) {
            ctlBriefingAffidavitSpouse.Filer = "J";
            ErrorTR.Visible = false;
            lblErrorMessage.Visible = false;
            ErrorTRBottom.Visible = false;
            lblErrorMessageBottom.Visible = false;
            if (!IsPostBack) {
                CheckCheckmarks();
                ctlBriefingOverview.Visible = true;
            } else {
                string ctrlname = Request.Params.Get( "__EVENTTARGET" );
                if(ctrlname.Length <= 0)
                    ShowNextControl();
            }
        }

EDIT: This code is also not mine. I'm trying to debug why it randomly broke. I've noticed it seems to be an issue with IE 99% of the time when doing this specific action.

Amanada Smith
  • 1,623
  • 9
  • 27
  • 41
  • 2
    you will have to post corrosponding code to figure out – Freelancer Jun 10 '13 at 04:40
  • 1
    Are you using ASP **Classic**, or **ASP.NET** ? You have tags for both - which cannot be - it's either classic or ASP.NET ..... – marc_s Jun 10 '13 at 04:59
  • possible duplicate of [What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net) – Josh Darnell Jun 10 '13 at 18:32

1 Answers1

1

The reason could be you are using Session variable or some other variable without checking it to null.
The error is suggesting that you have error on SourceIt.aspx page_load and error type is Object reference not set to an instance of an object.

What you can do is checking for null before using your Session variables.

Like if you are using say Session["UserId"].ToString() then you should check it for null first as below

 if(Session["UserId"]!=null)
    //wirte your code here.
शेखर
  • 16,910
  • 12
  • 52
  • 105