Hello,
How to cancel a async Ajax Request?
I have the following Controller where I querying a database async and have the need to cancel it if it runs to Long...
- Is it possible that using CancellationToken in ASP.NET Core is not possible?
- How to cancel such a Operation from the Client?
public async System.Threading.Tasks.Task<ActionResult> ReadAsync([FromBody] JsonDict jsonDict, [DataSourceRequest] DataSourceRequest request, CancellationToken cancelToken) { try { var queryDict = jsonDict["query"] as JsonDict; var optionsDict = jsonDict["options"] as JsonDict; var query = eqService.GetQueryByJsonDict(queryDict); var sql = eqService.BuildQuery(query, optionsDict); var result = await Db.QueryAsync<dynamic>(sql, commandType: System.Data.CommandType.Text,cancellationToken: cancelToken); return Json(result.ToDataSourceResult(request)); } catch (Exception ex) { return Json(ex); } }