Hi Rodrigo,
Thanks for your
patience.
You can achieve your requirement by throwing exception when token expires
during the Grid actions. The actionFailure event will triggered
on this exception and in that event, you can navigate to the login page.
In the below
sample, we throw exception while deleting a record from Grid.
actionFailure: https://ej2.syncfusion.com/javascript/documentation/api/grid/#actionfailure
[index.cshtml]
@Html.AntiForgeryToken()
<div>
<ejs-grid id="assetgrid21" actionFailure="actionFailure" allowPaging="true" allowGrouping="true" allowsorting="true" allowFiltering="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel", "Search" })" height="300" load="onLoad" >
</ejs-grid>
</div>
<script>
function onLoad() {
this.dataSource.dataSource.headers
= [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }];
}
function
actionFailure(args){
if(args &&
args.error && args.error[0] && args.error[0].error &&
args.error[0].error.responseText.indexOf("Token
Expired")){
alert("Token Expired");
window.location.rel='nofollow' href = "/Login"; // navigate to another page
}
}
</script>
|
[index.cshtml.cs]
public JsonResult
OnPostRemove([FromBody] CRUDModel<OrdersDetails> value)
{
throw new Exception("Token
Expired");
---
}
|
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/razor_grid_delte_navigate_to_login-1851489708.zip
Please get back
to us if you need further assistance.
Regards,
Rajapandiyan S