It's not much, but:
For the Forms Authentication timeout I just set the Web.Config and let it do it's thing:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="1"/>
</authentication>
For the sessionState timeout I modified a suggestion I found in one of these threads:
Web.Config:
<sessionstate timeout="1" />
In the Global:asax.cs:
Added in RegisterGlobalFilters() (called from Application_Start())
filters.Add(new CheckSessionOutAttribute());
Added this class:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class CheckSessionOutAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower();
if (!controllerName.Contains("account"))
{
HttpSessionStateBase session = filterContext.HttpContext.Session;
var user = session["UserName"];
if (((user == null) && (!session.IsNewSession)) || (session.IsNewSession))
{
var url = new UrlHelper(filterContext.RequestContext);
var loginUrl = url.Content("~/Account/Login");
filterContext.HttpContext.Response.Redirect(loginUrl, true);
}
}
}
}
Note: for testing each I modify the Web.Config timeout values so that I know which one I'm getting.
I know the application is just doing what it's told to do - the click in the KendoUI treeview is directing to the detail-pane, which is where the Login screen in getting loaded. I'm trying to figure out how to intercept all that at a higher level and just go to a full login screen, and close extra pages. Perhaps I need code in every view?
Here is the code for the treeview select to show the redirect, but I need to take a comprehensive action no matter what page/control is touched.
function Selected(e) {
var id = $('#ItemId').val();
var treeItem = treeview.dataItem(e.node);
$.post('@Url.Action("_Detail")', {
id: treeItem.id, actid: id
}, function (data) {
$('#detail-pane').empty()
$('#detail-pane').append(data)
});
}
Thanks - I'm relatively new on the MVC learning curve so I appreciate your patience.