tags:

views:

6

answers:

1

I'm trying to use a dummy TempDataProvider for some of my controllers.

The provider looks like this.

 public class NullTempDataProvider : ITempDataProvider {

    public IDictionary<string, object> LoadTempData(ControllerContext controllerContext) {
        return new TempDataDictionary();
    }

    public void SaveTempData(ControllerContext controllerContext, IDictionary<string, object> values) {

    }
}

But I'm getting an error that says

System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.Controller.PossiblyLoadTempData()

Any help for figuring out the reason for it is much appreciated.

A: 

By overriding CreateTempDataProvider() and returning an instance of NullTempDataProvider, this problem goes away.

Jova