Developer Forum »
WAFContext, WFContext, WAFRuntime
42 posts

Long, long ago I attempted to use WAFContext.Session.GetSite() when overriding OnNew(). The exception told me to use WFContext.Session..., and that worked, until one day I was creating a node using the front-end, and it told me to use a different session thingie.

So what should I use?

Could somebody please explain the differences between:

WAFContext.Session,
WFContext.Session,
WAFRuntime.SystemSession,
WAFContext.Engine.SystemSession,

and the list goes on...

This being one of the essential parts of Webnodes, it would be really great to have some documentation on this!

120 posts

Knowing how to get hold of the relevant webnodes user session can sometime be a little confusing, I agree!

In general:

If you are in a web context, use WAFContext.Session

If you are in a worflow context use WFContext.Session

If you do not know (or the code may run i both) you can use this method to determine the context:

WAFRuntime.Context

Possible values:

        switch (WAFRuntime.Context) {
            case WAFRuntimeContext.WebDialogue: return WAFContext.Session;
            case WAFRuntimeContext.WebEdit: return WAFContext.Session;
            case WAFRuntimeContext.WebVisit: return WAFContext.Session;
            case WAFRuntimeContext.WebOther: return WAFContext.Session;
            case WAFRuntimeContext.Workflow: return WFContext.Session;
            case WAFRuntimeContext.Internal: return WAFRuntime.SystemSession;
            default: break;
        }
 

This is however a little slow and has some performance issues as webnodes takes a few milliseconds to determine the context. So try not to use WAFContext.Context or WAFContext.ContextSession too much.

If you are working within a content class and overriding a property or method just use

  • this.Session

This will take the session that belongs to the instance of the content class, no matter which context was used to retrieve it. This is very fast and the recommened way to get hold of a session within a class.

Here is some existing documentation: (but I agree, it does not explain all of it)

http://developer.webnodes.com/long-running-tasks

http://developer.webnodes.com/working-with-content

Hope this helps!

42 posts

thanks :)

1