Hello,
- What is your product version? -- 7.0.0
- What is your product type (Angular or MVC)? -- Angular
- What is product framework type (.net framework or .net core)? -- .Net Core
In Aspnetzero application, how should I manage concurrency between request, when same request is posted multiple time .net core end up been creating same record twice.
How should I manage this at .Net Core to prevent multiuple same request.
9 Answer(s)
-
0
Hi,
You can take a look at https://docs.microsoft.com/en-us/ef/core/saving/concurrency.
Please let us know if you can't manage to implement it.
-
0
Hello @ismcagdas
Is there any other way we can achive database concurrency using IUnitOfWork or with some functionalities from ABP ? It would be great if you can share some example(that may have already been used in application) on how we can do it using aspnetzero code.
Thank you!
-
0
Hi @demo.solaru
ABP Framework doesn't offer an out of the box solution for this. Using EF Core's suggested approach is better I think. Have you tried it ? If so, did you face any problems ?
-
0
Hello @ismcagdas
We tried implementing it but because of async transaction (I guess, but not sure) its not working as expcated ... Is there anything we can check in with current unit of work in term of concurrent transactions?
-
0
Hi @demo.solaru
Did you get any errors ? If so, could you share it ? Upgrading your ABP NuGet package version might help here as well.
-
0
Hello @ismcagdas!
Here is how I am trying to implement: error is being catched when exception occurs but still end up being in "message": "An internal error occurred during your request!",
`public async Task
await CurrentUnitOfWork.SaveChangesAsync(); if (input.SaveAndSubmit) await SubmitInvoice(invoiceId); } catch (Exception ex) { if (ex is AbpDbConcurrencyException) { var inv = await _invoiceRepo.FirstOrDefaultAsync(i => i.InvoiceNumber.ToLower().Equals(input.InvoiceNumber.ToLower())); if (inv != null) return inv.Id; // Here it returns the value but it throws the error instead of returning the invoiceId throw ex; } else throw ex; } return invoiceId;
}`
Response
{ "result": null, "targetUrl": null, "success": false, "error": { "code": 0, "message": "An internal error occurred during your request!", "details": null, "validationErrors": null }, "unAuthorizedRequest": false, "__abp": true }
Here actual response should be end up being returning InvoiceId.
-
0
Hi @demo.solaru
Can you please share the relavant part of the log file. It is located in
aspnet-core\src\[YOURAPPNAME].Web.Host\App_Data\Logs\Logs.txt
-
0
Yes, please find attached!
Edited: URL removed due to sensitive data protection
-
0
Hi @demo.solaru I removed your url because you shared all of your log files and they may contain sensitive data.
As you may have noticed, the log files that you have shared contain too many lines. For this reason, it is very difficult to catch the error from there. Can you please reproduce the error and then copy just the relevant part of the log file content which is logged because of that error.