failed to load in the web form designer...

  • Thread starter Thread starter Jona Kee
  • Start date Start date
J

Jona Kee

I have web pages that inherit from a custom page class. I now get the
following error:

"The file failed to load in the web form designer. ... Object
reference not set to an instance of an object."

This occured after I added the following line of code in the base
class constructor:

if(User.Identity.Name.Length > 0)

Any way around this?

Thanks for your help.
 
As a guess, it looks like the constructor is executed when the form designer
loads? And at design time, that expression can't be evaluated, because User
is not set to anything.

My recommendation would be to put that code into Page_Init or Page_Load.
 
Back
Top