Home  /  Questions  /  Question



50   50
Jul 16, 2013


Returning a NULL object reference error when loading the web application

Hi,
 
I'm returning a null object reference when running the inital page.  The error occurs in the SavePageState method calling LoadProviders();


the _provider = _providers[section.DefaultProvider]; is returning a null value

I noticed that my section.providers returns a count of 0 from below.

The error occurs at _provider.SavePageState(name,viewstate); (actually error NullReferenceException was unhandled by user code.  I see a first and second in the viewstate object the first is Null.


Please note I'm not using the WCF since it was not necessary.

Regards,

var section = (ViewStateProviderServiceSection)
                            WebConfigurationManager.GetSection("myviewstateSection/viewstateService");                            

                        // Load all registered providers
                        _providers = new ViewStateProviderCollection();

                        ProvidersHelper.InstantiateProviders
                            (section.Providers, _providers,
                            typeof(ViewStateProviderBase));

                        // Set _provider to the default provider
                        _provider = _providers[section.DefaultProvider];

 
 1 comment
 
Hi guy! I got an error when I create a new project and using some class in Code folders. HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. This error showed when I used code below How to do to pass this error? Thank! --- Michael Ha  Dec 09, 2014