No errors and not save enithing to database when authentication timeout

2 posts, 0 answers
  1. pbondarchuk
    pbondarchuk avatar
    1 posts
    Member since:
    Aug 2007

    Posted 20 Nov 2014 Link to this post

    I am using latest trial Kendo.Mvc.dll
    I have grid with popup editing.

      .Sortable()
            .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.PopUp).TemplateName("Template").Window( w => w.Width(960)))       
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model => model.Id(p => p.NSTemplateID))              
                .Read(read => read.Action("Templates_Read", "TemplateManager").Data("additionalData"))                  
                .Update(update => update.Action("Templates_Update", "TemplateManager"))
                .Events(events => events.Error("error_handler").RequestStart("request_start"))                                 
            )

    All working good but when authentication timeout - no errors.
    How I can handle timeout and show warning to user?


  2. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 24 Nov 2014 Link to this post

    Hello,

    By default MVC will directly redirect to the login  page and will not return an error response so no errors will be shown. You could use a custom AuthorizeAttribute for the grid actions that returns a custom error as JSON and show the message in the dataSource error event e.g.
    public class DataSourceAuthorizeAttribute : AuthorizeAttribute
    {
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            filterContext.Result = new JsonResult()
            {
                Data = new DataSourceResult { Errors = new { authentication = new { errors = new[] { "message" } } } }
            };
        }
    }
    [DataSourceAuthorize]
    public ActionResult Update(...)


    Regards,
    Daniel
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top