Starts in:
0 DAY
15 HRS
59 MIN
27 SEC
Starts in:
0 D
15 H
59 M
27 S
Open Closed

Handle User Notifications in Blazor Server APP #1856


User avatar
0
david.hurtado created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.4.2
  • UI type: Blazor Server
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: No one
  • Steps to reproduce the issue: Generate a Blazor Server App

We been working on a Blazor (webAssembly) app, but we decide migrate to Blazor server, for get better performance on firsts loading.

Right now we been through some problems, one of then is User notify for validations and errors, in web assembly we got a modal windows message that indicate the error or validation. But now on Blazor server, we only get a console log notification in the browser.

Can anybody guide us for get older behaviour?

This is an example:

Before

The user left some field in blank

Now

Right now we got a message for reload page, and the user did not know what's happening

3 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @david.hurtado, please wrap your create and update methods with try-catch blocks and handle exception by yourself (by using HandleErrorAsync method). => https://support.abp.io/QA/Questions/1523/Blazor-Server-ABP-Exception-Dialog-not-shown#answer-7939465b-3349-3100-2cc1-39fd4fd8c78a

    And also, you can check the validations (are granted or not) inside of your create and update methods.

    private Validations NewSalesmanValidations { get; set; } //validation that used in your create modal
    
    //...
    
    private async Task CreateNewSalesmanAsync()
    {
       try
       {
          //if all validation rules are not validated, simply don't do anything  
          if (NewSalesmanValidations?.ValidateAll() == false) 
          {
             return;
          }
       
          await SalesmanAppService.CreateAsync(NewSalesman);
          await GetSalesmanAsync();
          CreateSalesmanModal.Hide();
       }
       catch (Exception ex)
       {
          await HandleErrorAsync(ex); //handles the exception and prevent app crash
       }
    }
    
  • User Avatar
    0
    david.hurtado created

    Thanks @EngincanV It's Works for Us.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    You're welcome. I am closing the question since your problem is resolved.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06