Kindly find the middleware code
Please share your recommendation.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
app.UseMiddleware(typeof(ErrorHandlingMiddleware));
app.UseMiddleware<TokenHandler>();
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'MemoryPool'. at System.Buffers.MemoryPoolThrowHelper.ThrowObjectDisposedException(ExceptionArgument argument) at System.Buffers.SlabMemoryPool.Lease() at System.IO.Pipelines.Pipe.AllocateSegment(Int32 sizeHint) at System.IO.Pipelines.Pipe.AllocateWriteHeadSynchronized(Int32 sizeHint) at Microsoft.AspNetCore.Server.IIS.Core.OutputProducer.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.<>c__DisplayClass335_0.<g__WriteFirstAsync|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Text.Json.JsonSerializer.WriteAsyncCore(Stream utf8Json, Object value, Type inputType, JsonSerializerOptions options, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|29_0TFilter,TFilterAsync at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNextTFilter,TFilterAsync at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at DesktopEngine.Helper.TokenHandler.Invoke(HttpContext context) in C:\DesktopEngine\Helper\TokenHandler.cs:line 62 at DesktopEngine.MiddleWare.ErrorHandlingMiddleware.Invoke(HttpContext context) in C:\DesktopEngine\MiddleWare\ErrorHandlingMiddleware.cs:line 26|
How to fix this?