My ASP.NET MVC 3 app uses an web service which passes an custom user object to the app. Sometimes, without reason, this user object just doesn't instantiate when I call a method to return an user object from my web service, so I get an Object not set to an instance of an object error. The only way I'm able to fix this is by recycling my App Pool of my web service in IIS, I have no idea what could be causing this so was wondering if this is a common problem and if so, is their a way to fix it?
This is the line which returns no data:
PZServicesClient client = new PZServicesClient();
var user = client.GetUser(HttpContext.User.Identity.Name);
As soon as I recycle the App Pool it instantly starts working again.