Iron Speed Designer Help
 

Access Session State Information in Applications

Updated June 5, 2006
Iron Speed Designer V4.0 and later

Session variables can be used to pass values across pages in an application because information stored in the Session object is available throughout the session and has session scope.  For example, you can store control values in session variables and access them in another web form.  You can use this technique to pass information from page to page when creating a series of wizard pages to add a record.  Or, you can store information about a signed-in user in a session object for later use in a “WHERE “clause when initializing a control or in other custom code.

Accessing session variables

Session objects can be set in any BaseClasses methods, events or custom functions.  Similarly Session objects can be accessed anywhere in your application.  In some cases, you may be able to access the .NET Session class directly.  If you cannot access the Session class directly, you may need to specify its full path as follows:

In C#, to access a session value:

System.Web.HttpContext.Current.Session[“MyVariable”]

(string) System.Web.HttpContext.Current.Session[“MyVariable”]

In C#, to set a session value:

System.Web.HttpContext.Current.Session[“MyVariable”] = “NewValue”

In Visual Basic .NET, to access a session value:

System.Web.HttpContext.Current.Session(“MyVariable”)

System.Web.HttpContext.Current.Session(“MyVariable”).ToString()

In Visual Basic .NET, to set a session value:

System.Web.HttpContext.Current.Session(“MyVariable”) = “NewValue”

Sharing State between Applications

Iron Speed Designer builds standard Microsoft .NET applications.  If you want to share session states across applications, you may want to review some of the online help available on how to accomplish this in Microsoft .NET applications.  Here are some links that you might find helpful.

http://www.asp101.com/articles/jayram/sharestate/default.asp

http://searchvb.techtarget.com/vsnetATEAnswers/0,293820,sid8_gci1011277_tax293672,00.html

Using the SessionNavigationHistory class

You can use the .NET SessionNavigationHistory class to perform actions in pages based on where your user came from in the application.  For example, you can obtain the previous URL in the SessionNavigationHistory list using the GetPreviousRequest method.  Here’s how to define and use the SessionNavigationHistory class:

Dim str As BaseClasses.Web.SessionNavigationHistory = Me.GetSessionNavigationHistory

Dim stry As BaseClasses.Web.SessionNavigationHistory.RequestInfo = str.GetPreviousRequest()

See Also

ASP.NET State Management Overview:

http://support.microsoft.com/default.aspx?scid=kb;en-us;307598

Session State Overview in .NET Framework Developer's Guide:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsessionstate.asp