How to use Session with the Nancy Razor ViewEngine
Question
I'm using the RazorViewEngine for NancyFx and I would like to have a ViewBag like object where I can store dynamic properties. Although not ideal, I decided that Session state would suffice for my purposes. I've enabled CookieBasedSession in my Bootstrapper's ApplicationStartup method, and I added a BeforeRequest Pipeline method to set the Session variable. However, I don't know how to retrieve the value in my View. Is this possible, without adding the Session variable to a model? Is the Session state only meant to be accessed in modules?
(cross posted from the nancy-fx forum)
Solution
As of right now you will need to pass in the values though your view model. There is no direct access to the session state from inside a view