May 29, 2013 at 7:38 AM
Edited May 29, 2013 at 7:57 AM
I have the following StateInfo config:
  <dialog key="ListUpdates" initial="all" path="~/Default.aspx">
    <state key="all" page="~/Views/Index.aspx"></state>
  <dialog key="CreateUpdate" initial="input">
    <state key="input" page="~/Views/Create.aspx">
      <transition key="inputToIncidents" to="incidents"></transition>
    <state key="incidents" page="~/Views/Incidents.aspx">
      <transition key="incidentsToInput" to="input"></transition>
I am storing an object in the session with an ID of StateContext.Bag.SessionID:
public UpdateViewModel ViewModel { get { return HttpContext.Current.Session[SessionID] as UpdateViewModel; } set { HttpContext.Current.Session[SessionID] = value; } }
StateContext.Bag.SessionID is set in the 'input' state of dialog 'CreateUpdate'.

When I navigate to the 'incidents' state using a NavigationHyperLink, the StateContext.Bag.SessionID is null when the gridview binds to the select method. Even though it appears in the URL.

How do I access the StateContext.Bag.SessionID value?
May 29, 2013 at 8:04 PM
Edited May 29, 2013 at 8:05 PM
I really like what you're doing. I've used the same approach where the Navigation framework remembers the navigation path while the Session remembers the data.

From what I can see you're doing everything right apart from when you build the NavigationHyperLink. To make the ID available to the 'incidents' State you must pass it in the NavigationHyperLink. The simplest way to do this is by setting the IncludeCurrentData flag of the NavigationHyperLink to true, that way all the data in the current StateContext will be passed to the next State:
<nav:NavigationHyperLink ID="IncidentsLink" runat="server" Action="inputToIncidents" IncludeCurrentData="true" />
Alternatively, if you want more control over the data passed you can build the NavigationData manually:
IncidentsLink.ToData = new NavigationData() { { "SessionID", StateContext.Bag.SessionID } };
Thanks for the question and I hope this helps.
May 29, 2013 at 11:46 PM
Thanks Graham. This seems to be working now.

It's not a problem, but for the purists (I work with a few..), if you use the IncludeCurrentData attribute, the SessionID is repeated in the query string twice. I haven't whether this happens when the NavigationData is passed in the hyperlink.

It doesn't bother me (and may be intended behaviour anyway seeing as the SessionID exists in 2 StateContext's.

Thanks for the kind words. I am using this project as a proof of concept to see if Navigation solves our issues with concurrency and standardisation.
May 30, 2013 at 7:32 PM
The SessionID appears twice regardless of whether IncludeCurrentData is set to true or the NavigationData is built manually. It's stored once for back navigation to the 'input' State and a second time for forward navigation to the 'incidents' State.

I'd be interested to find out whether Navigation does solve your issues and anything I can do to help you out just let me know.