global exception view not opening when the datagrid gets an error.

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,


10 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team January 3, 2022 12:54 PM UTC

Hi John, 

Greetings from Syncfusion support 

We understand that you are maintain a global exception in your application and facing the problem. Before we start providing solution on your query, we need some information for our clarification. Please share the below details that will be helpful for us to provide better solution. 

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. 

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. 

Note: By default, if any Grid actions fails while execution, it will trigger the actionFailure event. You can also call your exception in actionFailure event.  

Regards, 
Rajapandi R 



JT John Taylor January 3, 2022 01:13 PM UTC

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?





RR Rajapandi Ravi Syncfusion Team January 4, 2022 01:47 PM UTC

Hi John, 

Thanks for the update 

We have checked your query at our end, but we are not able to reproduce your reported problem at our end. So please share the below details that will be helpful for us to provide better solution. 

1)       Please share your issue replication procedure step by step. 

2)       Please share your issue scenario in video demonstration format. 

3)       In your query you have used “app.UseExceptionHandler("/Home/Error")” in startup to handle the global exception. So please share the video demo about at what case you trigger this and  
          handle the exception and also confirm you like to trigger this for handling Grid error. 

4)      If possible, please share the issue reproducing sample that will be helpful for us to validate. 

Regards, 
Rajapandi R 



JT John Taylor January 20, 2022 05:36 PM UTC

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



RR Rajapandi Ravi Syncfusion Team January 21, 2022 12:29 PM UTC

Hi John, 

Thanks for the update 

By default, in our EJ2 Grid, when the exceptions throw in our built-in method, we have catch that exception and triggered our actionFailure event to show the error details. Since your requirement is about navigate to another page you need to bind actionFailure event and from here you can navigate to your Error page. Please refer the below code example and sample for more information. 

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"); 
        } 




Regards, 
Rajapandi R 


Marked as answer

JT John Taylor replied to Rajapandi Ravi January 30, 2022 09:40 AM UTC

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");

             }



RR Rajapandi Ravi Syncfusion Team January 31, 2022 12:56 PM UTC

Hi John, 

Thanks for the update 

In our previous update, we have shared the sample in production environment. So, before we start providing solution on your query, we need some information for our clarification. So please share the below details that will be helpful for us to provide better solution. 

1)         Please confirm your application is in development or production environment. 

2)         If it was in development, please change your application environment as production. 

3)         If still you face the problem, please share the issue scenario in video demonstration format. 

Rajapandi R 



JT John Taylor February 1, 2022 10:51 AM UTC

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,



Attachment: WebApplication7_d0657a55.rar


RS Rajapandiyan Settu Syncfusion Team February 2, 2022 04:15 PM UTC

Hi John, 

Sorry for the inconvenience caused. 

We can reproduce the reported behavior (“it enters the Error action 2 times”) in the given sample. Currently, we validating this at our end. We will update the further details on or before Feb 7th, 2022. 

We appreciate your patience until then. 

Regards, 
Rajapandiyan S 



SK Sujith Kumar Rajkumar Syncfusion Team February 9, 2022 12:28 PM UTC

Hi John, 
 
Thanks for your patience. 
 
When the CRUD action(except for edit action where entire refresh will not occur) is performed on Grid with remote data binding, the entire refresh will only occur when the response is returned back to the Grid. However when exception is thrown from the server side CRUD action method from where the error view page is called, this default action will be stopped. Because of this only partial page refresh will occur and that is why the entire error page content is not displayed for your case. So we had shared you the previous solution where we have manually invoked the error page view in order to completely reload for displaying the error view page which will cause the error page to be invoked twice. This is the default behavior of this case and so we suggest you to use the shared solution to achieve your requirement. 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 


Loader.
Up arrow icon