locked
Page throws exception in server while calling from default.aspx RRS feed

  • Question

  • User1022158690 posted

    In my default.aspx, I am calling the docPage.aspx in following manner after setting up session values.

     Session["docType"] = commandArgs[0];
                Session["docName"] = commandArgs[1];
                Session["profile"] = searchParam;
                ScriptManager.RegisterStartupScript(
                    Page, typeof(Page), 
                    "OpenWindow",
                    "window.open('docPage.aspx');", 
                    true);

    And in my docPage.aspx I retrieving the values and using accordingly. It works fine while debugging but as soon as I deploy it to local IIS the docPage.aspx is loaded with following exceptions. any resolution or suggestion would be handy.

    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.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Default2.Page_Load(Object sender, EventArgs e) +60
       System.Web.UI.Control.OnLoad(EventArgs e) +108
       System.Web.UI.Control.LoadRecursive() +67
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4497
    
    Wednesday, September 28, 2016 3:10 PM

Answers

  • User-2057865890 posted

    Hi Ali_0087,

    A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. To address this issue, make sure that the argument is not null, or handle the thrown exception in a try…catch…finally block.

    reference: https://msdn.microsoft.com/en-us/library/system.nullreferenceexception(v=vs.110).aspx 

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 29, 2016 8:08 AM
  • User3690988 posted

    My guess is that one of your session variables is null where you are using it in the Page_Load event in class Default2.

    Are you sure they are being set in default and do you check to ensure they are valid before using them in Default2.

    Is the environment that you deploy to a server farm, or does it load balance?  This could cause the session variables to be lost.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 30, 2016 4:09 PM

All replies

  • User-2057865890 posted

    Hi Ali_0087,

    A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. To address this issue, make sure that the argument is not null, or handle the thrown exception in a try…catch…finally block.

    reference: https://msdn.microsoft.com/en-us/library/system.nullreferenceexception(v=vs.110).aspx 

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 29, 2016 8:08 AM
  • User3690988 posted

    My guess is that one of your session variables is null where you are using it in the Page_Load event in class Default2.

    Are you sure they are being set in default and do you check to ensure they are valid before using them in Default2.

    Is the environment that you deploy to a server farm, or does it load balance?  This could cause the session variables to be lost.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 30, 2016 4:09 PM