PDA

View Full Version : Ext.Direct .NET Router and SessionManagement



Whatty
17 Dec 2009, 9:38 AM
Good afternoon,

Is there a mechanism for session management in the Ext.Direct implementation or can anyone provide me with a strategy for handling session management in .NET.

I was hoping for a similar mechanism that is found in the DirectJngine on the Java side but obviously for .NET.

Alternatively, if this has already been handled if you could point me at that implementation it would be greatly appreciated.

Thanks in advance.

Whatty
18 Dec 2009, 4:51 AM
Ignore, I found it finally in another post on the Ext.Direct impl for .NET



FYI: In order to access the Session in Direct methods, your generic web handler needs to implement IRequiresSessionState or IReadOnlySessionState (for read only access).

For example, your handler should look like:
public class MyHandler: DirectHandler, IRequiresSessionState


and then you can use something like the following in your classes



/// <summary>Retrieve an object from the session.</summary>
///
/// <param name="name">the name in of the object in the session.</param>
///
/// <returns>the session object</returns>
///
protected Object getSessionObject(String name) {
Object sessionObject = null;
HttpContext contextManager = HttpContext.Current;
if (contextManager != null) {
HttpSessionState session = contextManager.Session;
if (session != null)
{
sessionObject = session[name];
}
}
return sessionObject;
}

/// <summary>Store an object in the session</summary>
///
/// <param name="name">the name in which to store the object under.</param>
/// <param name="anObject">the object to store.</param>
///
protected void storeSessionObject(String name, Object anObject) {
HttpContext contextManager = HttpContext.Current;
if (contextManager != null) {
HttpSessionState session = contextManager.Session;
if (session != null)
{
session.Add(name, anObject);
}
}
}


Assuming of course that you have dealt appropriately with the empty session issue, this should allow you to stuff and retrieve objects from the session.

Whatty

1414211340@qq.com
23 Jun 2013, 5:43 AM
学习Ext.Direct