It's a pretty straight forward question. I'd like to be able to provide feedback to the user about the result of a postback using TempData (since it's auto-cleared). On successful execution of an action accepting a postback, I forward to a view dedicated to showing the result of the action, and would like to use TempData but leave SessionState disabled. For now the CookieTempDataProvider
included in MVC3 Futures works great, but it doesn't seem like my implementation of IDependancyResolver
is ever called to look for anything that implements ITempDataPovider
.
Was this an oversight?
Anyone else tried this yet?
you can do this by creating a new controllerfactory which is requested by IDependancyResolver
Then in your dependancy resolver set it to look for IControllerFactory, and return your ITempDataProvider
example for ninject:
Depenency injection is not used to look up instances of
ITempDataProvider
in MVC 3. The DI work done in MVC 3 was meant to expose the most frequently requested DI seems.The only way to customize the instance of
ITempDataProvider
is to override theController.CreateTempDataProvider
method.