Base solution for your next web application
Open Closed

Change language of error messages #4377


User avatar
0
moustafa created

Hello everyone this question is has nothing to do with ASP.NET Zero in web.config as the application has multiple languages

<globalization culture="auto" uiCulture="auto" />

so the problem is i need to see errors messages (exceptions) in English only and the same for log, not depending on the current culture selected by the user , and i cannot set uiCulture to "en-GB" in web.config that will cause a problem and the localization will not work except for English.

Any ideas?


1 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    You can replace AbpExceptionFilter then do:

    public void OnException(ExceptionContext context)
    {
        // ...
        
        using (CultureInfoHelper.Use("en"))
        {
            if (wrapResultAttribute.LogError)
            {
                LogHelper.LogException(Logger, context.Exception);
            }
    
            if (wrapResultAttribute.WrapOnError)
            {
                HandleAndWrapException(context);
            }
        }
    }
    

    Replacing may be a bit tricky. You can try #641 (comment) or this answer.