mirror of https://github.com/abpframework/abp.git
Browse Source
This change hardens `AbpUnitOfWorkMiddleware` to avoid invalid second completion attempts when the response starts during end-of-pipeline UoW completion, and to skip early completion while a shared child UoW scope is still active. It adds active child-scope tracking in `UnitOfWorkExtensions`/`ChildUnitOfWork`, updates option docs to clarify behavior, and adds MVC tests plus controller/event-handler scenarios covering child-scope response flush and event-driven response writes during completion.pull/26017/head
7 changed files with 142 additions and 7 deletions
@ -0,0 +1,34 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Uow; |
|||
|
|||
public class ResponseWritingTestEvent |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Writes to the HTTP response from a local event handler. When the event is published inside the
|
|||
/// request unit of work, this runs during the unit of work completion at the end of the pipeline
|
|||
/// and starts the response from inside that completion.
|
|||
/// </summary>
|
|||
public class ResponseWritingTestEventHandler : ILocalEventHandler<ResponseWritingTestEvent>, ITransientDependency |
|||
{ |
|||
private readonly IHttpContextAccessor _httpContextAccessor; |
|||
|
|||
public ResponseWritingTestEventHandler(IHttpContextAccessor httpContextAccessor) |
|||
{ |
|||
_httpContextAccessor = httpContextAccessor; |
|||
} |
|||
|
|||
public async Task HandleEventAsync(ResponseWritingTestEvent eventData) |
|||
{ |
|||
var response = _httpContextAccessor.HttpContext?.Response; |
|||
if (response != null) |
|||
{ |
|||
await response.WriteAsync("event-written"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue