Accessing the Session

The session is central in Relatude. You access all the content through the session. This means that all the content you get back is automatically filtered for access rights for the current user.

Accessing the session in Controllers

To access the Session of the user in a controller, you normally access it with the WAFNativeContext. The WAFNativeContext object is accessed by injecting it in your controller like this:

public class ArticleController : Controller {
        WAFNativeContext _ctx;
        public ArticleController(WAFNativeContext ctx) {
            _ctx = ctx;
        }
        public IActionResult Index() {
            var c = _ctx.Request.GetContent<ArticleBase>();
            return View(c);
        }
    }

Accessing the session in the content object

When you have retrieved a content object, the Session is available as a property on the content object:

public override void OnBeforeUpdate() {
            if (this.IsChecked) {
                var session = this.Session;
                var articles = session.GetContents<ArticleBase>();
            }
             base.OnBeforeUpdate();
        }