SessionState required for tempdata in Preview 4

Last post 07-17-2008 1:12 PM by Wargrip. 1 replies.

Sort Posts:

  • SessionState required for tempdata in Preview 4

    07-17-2008, 1:06 PM
    • Member
      8 point Member
    • Wargrip
    • Member since 05-15-2008, 6:20 PM
    • Posts 7

    Hi, In our application we disable session state but with preview 4 there is an exception raised when loading a controller:

     The provider requires SessionState to be enabled.

    I know there is a ITempDataProvider interface now and I tried to add:

    this.TempDataProvider = null;

     Into the constructor of my controller but it seems the temp data attempts to load before the controller is executed (according to the stack trace).

    Is there any way to disable the loading of the TempData so I don't have to re-enable session state?

     Thanks!

    Gavin

  • Re: SessionState required for tempdata in Preview 4

    07-17-2008, 1:12 PM
    Answer
    • Member
      8 point Member
    • Wargrip
    • Member since 05-15-2008, 6:20 PM
    • Posts 7

    Nevermind - solved it... if anyone else has this problem, they can use the following code:

    public class NullTempDataProvider : ITempDataProvider

    {

    #region ITempDataProvider Memberspublic TempDataDictionary LoadTempData()

    {

    return new TempDataDictionary();

    }

    public void SaveTempData(TempDataDictionary tempDataDictionary)

    {

    }

    #endregion

    }

     Then in the constructor of your controller:

    this.TempDataProvider = new NullTempDataProvider();

    Hope this helps someone.

    Cheers

    Gavin

Page 1 of 1 (2 items)