I got a master page with a server control in it. Randomly the server control is inaccessible from codebehind. This doesn’t happen on a specific action (eg a Button click or so). Currently I have no clue what this could be. I don’t think it’s output caching since this is not explcitly activated and the error happens far to seldom for that. But I’m going to disable caching in the master page explicitly with next deployment.
Anyone an idea how to find more info to find what’s happening? Or has someone had a similar error?
The control is defined in markup. The accompaning codebehind is:
PGFMainNavi.HasAccessToFunction = HasAccessToNaviItem;
// HasAccessToNavi is a local function
Exception is:
System.NullReferenceException: Object reference not set to an instance
of an object
Thanks.
sa
I have similar errors when I cache my controls – and I always check if their null, or if they are the correct types.
I think that your control is cached somewhere.
Use this code, to check that is not cached.
or find where you set the case on this control and remove it.
Second Solution
Some times after an online update I get this error, because compiler did fail to read correct all involving files – probably some user read the page the same time I copy the files or something.
To avoid that I always use the app_offline.htm before make my updates.