Hi,
I defined a global error page in Startup.cs Configure method. (app.UseExceptionHandler("/Home/Error");)
If for some reason the datagrid gets an error, the Error action works but does not redirect to the Error View. Datagrid comes as empty without any error message. Why is the global exception view not opening when the datagrid gets an error?
Br,
1) In your query you have mentioned that you have maintained a global exception, so please share the details about how you call the exception.
I added app.UseExceptionHandler("/Home/Error") to Configure method of Startup.cs. UseExceptionHandler can be used to handle exceptions globally.
2) Please confirm at what case you like to call the exception and also please confirm if any error occurs in the Grid you like to call the exception or you have handled any event to call the exception.
Normally, when I throw excepiton from the controller, the error page should be opened as per the definition I mentioned above. However, the grid page does not redirect to the error page and does not show any errors. Should I make a different definition on the grid page?
Hi,
I have attached the sample project for you to review. I added app.UseExceptionHandler("/Home/Error") to Configure method of Startup.cs. I also throw an exception in the insert of the main grid. You can see the situation I mentioned by entering something on the main grid, doing the Add and pressing the Update button, and throwing an error. It comes to the Error action in the Home Controller, but the page does not redirect to the Error view and the error does not appear on the grid. The screen remains as if nothing happened. If there is an error, I want it to be directed to the Error view.
Br,
Attachment: GridErrorSample_981c4a81.rar
|
Index.cshtml
<ejs-grid id="Grid" actionFailure="failure" >
<e-grid-columns>
. . . . . . . .
. . . . . . . .
</e-grid-columns>
</ejs-grid>
<script>
function failure(args) { //actionFailure event of Grid
var url = '@Url.Action("Error", "Home")';
window.location.rel='nofollow' href = url; //when the exception occurs the actionFailure event gets triggerd
} and from here you can redirect to your page
</script>
|
|
HomeController.cs
[Route("/Home/Error")]
[AllowAnonymous]
public IActionResult Error()
{
// Retrieve the exception Details
var exceptionHandlerPathFeature =
HttpContext.Features.Get<IExceptionHandlerPathFeature>();
//return Redirect("~/Error/Error");
return View("Error");
}
|
Hi,
After making the changes you mentioned, something like this happened. In the code snippet below in startup.cs, there is no problem in the development environment, but when we are not working in the development environment, it enters the Error action 2 times with the example you gave, which prevents it from getting the correct error message.
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
Hi,
You did not fully understand the problem. I made the changes you mentioned in the previous post. I throw an exception while doing Add to Grid. If you check in the attached code, you will see that it enters the Home/Error action twice, not once.
Br,