This is a migrated thread and some comments may be shown as answers.

No errors and not save enithing to database when authentication timeout

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pbondarchuk
Top achievements
Rank 1
pbondarchuk asked on 20 Nov 2014, 11:18 AM
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?


1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Nov 2014, 09:26 AM
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.

 
Tags
Grid
Asked by
pbondarchuk
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or