Open Closed

Throwing UserFriendlyException is throwing actual exception rather than being displayed as a dialog #9555


User avatar
0
cstobler created

When execution reaches my 'throw new UserFriendlyException("string")' line, it throws an actual exception rather than showing as a dialog as it used to do before i upgraded my project to Pro and .NET 9:

I assume there is some misconfiguration here, but I can't find it in any documentation online. Please show me how I can get back to having this display to the user in a dialog.


9 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In ABP MVC applications, throwing a UserFriendlyException should display a user-friendly dialog instead of the raw exception page. If you are seeing the raw exception after upgrading to .NET 9 or ABP Commercial Pro, it is likely due to a missing or misconfigured exception filter or middleware.

    • Ensure you have the AbpExceptionFilter enabled in your MVC pipeline. In your Startup.cs or module configuration, make sure you have:

      services.AddAbpMvcExceptionHandling();
      
    • Also, check that you are not running in the Development environment, as the Developer Exception Page will override ABP's user-friendly dialog. In production, ABP's exception handling will show the dialog.

    • If you have custom error handling middleware or filters, ensure they do not interfere with ABP's exception handling.

    • For more details, see the official documentation:

      • https://docs.abp.io/en/abp/latest/Exception-Handling#user-friendly-exception

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    cstobler created

    I don't see services.AddAbpMvcExceptionHandling(); in my WebModule.cs, so I was looking to add it, but I doesn't seem to be available to add under context.services in the ConfigureServices method. I think I am still missing something here.

    If you need access to my project, it was emailed for a previous ticket: 9542.

  • User Avatar
    0
    alper created
    Support Team Director

    this is development page for errors, try to run it in release mode also environment variable = release

  • User Avatar
    0
    cstobler created

    Would you mind spelling this out for me a bit more? Is this the ASPNETCORE_ENVIRONMENT variable, or another one? I tried experimenting with utilizing app.UseErrorPage() in dev rather than app.UserDeveloperExceptionPage(), and that didn't seem to do anything. It's very possible I am grossly misunderstanding how to go about this, but any advice would be appreciatd.

  • User Avatar
    0
    alper created
    Support Team Director

    there's a condition like this:

  • User Avatar
    0
    cstobler created

    Thanks for pointing that out. I do have that configured, but it is also failing in production as well (this error only arises when I throw a UserFriendlyException shown below):

    Here is my OnApplicationInitialization method:

    It is throwing the 500 error when it hits this line:

    I didn't change anything here other than upgrading to Pro, so I think something must have gone awry (which wouldn't be surprising since I had other issues after upgrading). I don't think it should be throwing a 500 error when I throw a UserFriendlyException.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can add try catch when calling the application service in your razor page. Because your page return type is page(IActionResult) instead of object.

    public virtual async Task<IActionResult> OnPostAsync()
    {
        try
        {
            await AppService....
        }
        catch (UserFriendlyException e)
        {
            Alerts.Danger(L["Your messag"]);
            return Page();
        }
    }
    

    Thanks.

  • User Avatar
    0
    cstobler created

    Ok, it seems like maybe in the past when I was getting the user friendly exception dialog, it was because I was using an AJAX request. Using try-catch in the razor page model should allow me to get close to what I need. Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on July 11, 2025, 11:35