1

I have an asp.net page that gets loaded inside a customer's website. It loads fine the first time, but when the customer clicks a button, it crashes with the "object reference not set to an instance of an object" error. The log shows that the error occurred in the this.Master line (see below):

protected override void OnInit(EventArgs e)
{
    _master = (CustomMasterPage)this.Master; //this is the line where exception occurs
    //...some other code
}

What I know so far:

  • I can't reproduce the error in neither DEV nor QA environments.
  • I can't reproduce the problem when the inner page is executed on its own, outside of the client's page.
  • Our prod servers are load-balanced, but it shouldn't be a session issue, right? Even if I was suddenly served a brand new instance of Session, "this" still would not be null as it gets created by Asp.Net as part of request/response. All the custom values would disappear, yes, but "this" should still exist, right?

So, I'm looking for ideas explaining why 'this' would suddenly become null in the described scenario, thanks!

Alexey Nagoga
  • 181
  • 1
  • 6
  • That is wierd. Can you try adding some logging, just before the `_master = (CustomMasterPage)this.Master;` line, to output 'this' ? Also look at the page markup to see if it has @MasterType defined - answers to this question explain this attribute further - https://stackoverflow.com/questions/8946742/why-we-use-master-type – sh1rts Feb 05 '20 at 20:57
  • Can you show us the `Page` directive of your content page? – Jamshaid K. Feb 05 '20 at 22:24

0 Answers0