Reputation: 3615
I am having an issue with my application. The web application is quite large and works by using a number of ascx and VB server controls, each of which does various partial post backs using update panels. Everything works fine on my local machine but when I push my application to the server (IIS) I notice that my application will throw an error during an update of an update panel. Here is the error:
Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
I'm not sure what is causing this error or how to track down which control is causing this problem. I've tried debugging the live application using IE's Developer Tools. The error seems to be originating from a web resource, MicrosoftAjaxWebForms.debug.js. The function that is having the problem is:
_endPostBack: function PageRequestManager$_endPostBack(error, executor, data) {
if (this._request === executor.get_webRequest()) {
this._processingRequest = false;
this._additionalInput = null;
this._request = null;
}
var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
Sys.Observer.raiseEvent(this, "endRequest", eventArgs);
if (error && !eventArgs.get_errorHandled()) {
throw error;
}
},
The data variable is coming across as null. Anyone know how to address this problem or how to find out specifically which control on my page is causing the issue?
Thanks for any help Jason
Upvotes: 2
Views: 7398
Reputation: 3615
This was actually a good "lessons Learned" for me. A little background on the application and the problem I was seeing. I decided I wanted to create an application that would use update panels as much as possible, to create a nice flowing application. In this way, I wanted to create an experience for the user that would make them think everything was synchronous had had no post backs or page transfers. The application was for our company and was also running on a local Intranet.
To help do this, i broke out each component of my application and created its own server control. For example, I had a group of controls added to one single user control (ASCX) that consisted of a modal dialog with gridviews, buttons, etc on it. To keep track of all the data coming and going, each control kept track of it's own data in session. For the most part, this data in the sessions were lists of objects. As the application grew (that is to say, as the user used the application, the sessions would grow) I would get intermittent errors. These errors only occurred when I pushed it out to our server but ran fine locally in debug and on my local IIS server. The error took me a few days to track down but ended up being an object would that was being kept in session would sporadically get "lost".
As it turned out, our IIS had a cap on in memory size. Once that cap was reached, IIS's App Pool would be restarted, causing all session to be reset. This did not occur locally because I had to cap. So, I had to re-think how data was being persisted. I ended up using view states for most of my data (which requires that the classes be serialized). I did have a control that could not use view states and had to rely on sessions. For this one, I made sure i added a method that could be called to clear out all session data when it was no longer needed.
In the future, I think I will do a few things differently. First, be more judicious with my use of Sessions. I'm not sure if there are any limitations on view states, but I have not yet experiences any issues. I also think I will stay away from update panels (the ajax control loolkit all together) and rely on regular ajax. Second, while update panels make for fast development the cost is heavier partial postbacks.
Upvotes: 3