Activities of "DominaTang"

Can close this ticket. I gave two short of lock grace period, and I also add a loop / sleep try n times to acquire the lock. Then the code works

We have a distributed lock code like this, but it seems, the second thread didn't wait till first thread finished db insert

await using var handle = await _distributedLock.TryAcquireAsync($"api-lock", TimeSpan.FromMinutes(5));
 try {
                    if (handle != null)
                    {
                        var rtCertifcate = _apiClient.CallApi (); //external API 
                        if (!string.IsNullOrWhiteSpace(rtCertifcate ))
                        {
                           //insert into database for rtCertifcate 
                           return rtCertifcate 
                        }
                    }
                    else
                    {
                        // If we can't acquire the lock, fall back to database lookup
                        Logger.LogWarning("....");
                    }
                    
}
catch 
{
}
//Code read certificate from database

Copy Response is exact the text as shown above, I throw the User Friendly Exception at the first line of a AppService method for testing. The response status code is 400

The backend is as above in Api project. The client angular network tab, response is plain error message.

If the API call handle the error message, the Angular UI does catch the UserFriendlyException message, say the angular show the message in a toaster or display direct on a UI element. However, at the same time, the Generic Internal Error exception window also shows up. I don't want the second one, or the second one should be message in UserFriendlyException

Actually I tried UserFriendlyException, BusinessException, Exception, from backend Swagger, the error code is 400, the response content is plain text error message, instead of JSON format. I have this code below in HttpApi.Host module file:

if (env.IsDevelopment())
{
//app.UseDeveloperExceptionPage();
}

app.UseCorrelationId();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseAbpExceptionHandling();

app.UseRouting();

Another interesting thing is, I use this code below in a controller method:

return StatusCode(400, new
{
    error = new
    {
        message = "Your user-friendly message in json",
        details = (string?)null,
        code = (string?)null
    }
});

The angular side doesn't display the message neither

ABP 8 MicroService architect, when backend throw an UserFriendlyException, the message not showing in Angular client, instead an Internal error message is shown

Question

ABP framework 9, the customize Login page can remove self registration link, how to disable this feature so that swagger API also has no this API (api/account/register)

Answer

Another approach that worth a try is using Aspire.Net. Here is AI's answer: Never use it, but it seems worth a try.

.How to Use Aspire for Integration Testing: Add the Testing Package: Include the Aspire.Hosting.Testing NuGet package in your test project. Create a Test Host: Use DistributedApplicationFactory<TProgram> to create a factory that can launch your Aspire app host for testing. Configure the Test Environment: Define any necessary environment variables or containerized resources required for your tests within the DistributedApplicationFactory setup. Interact with Services: Obtain HttpClient instances or other client proxies from the DistributedApplicationFactory to interact with your services under test. Write Assertions: Implement test assertions to verify the expected behavior and interactions between your microservices. Clean Up Resources: Ensure proper disposal of the DistributedApplicationFactory to clean up resources after tests complete.

Showing 1 to 10 of 177 entries
Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
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 September 12, 2025, 10:20