Questions tagged [asp.net-core-middleware]
Questions about Asp.Net Core's application pipeline that handles requests and responses.
asp.net-core-middleware
413
questions
0
votes
1
answer
30
views
app.UseStatusCodePagesWithReExecute Does Not Seem to Execute Pipeline Again
In my .NET 7 web site, I've set up the processing pipeline to use UseStatusCodePagesWithReExecute but with a registered middleware in the pipeline returns 404, it correctly returns the 404.cshtml page,...
-1
votes
1
answer
47
views
If Migration is not sent to the database, UseExceptionHandler Middleware will not work. Why?
I added a new property in a entity class. I didn't create migration. After that, I tried to use UseExceptionHandler middleware. It successfully triggered error action method but the view didn't appear....
0
votes
1
answer
75
views
Best Practices for using middleware in ASP.NET Core Web API for exception handling, authentication, and error logging
I'm working on an ASP.NET Core Web API project and I am trying to implement some global functionalities using middleware. Specifically, I want to handle the following:
Global exception handling: ...
0
votes
1
answer
75
views
ASP.NET Core is logging "request unhandled" even though it is handled by my middleware
I have some middleware which sets a response status code, content type and content (with SendFileAsync) yet the log file contains a debug message from Microsoft.AspNetCore.Hosting.Diagnostics saying &...
0
votes
1
answer
80
views
Access response body in middleware unit test
I have a .net middleware that modifies the response and I'm trying to unit test it. I am able to successfully assert the status code and content type are correct, but when I attempt to assert the ...
0
votes
0
answers
58
views
Using ASP.NET Core 8 Web API project : I am trying to access controller and its attributes from middleware
In my ASP.NET Core 8 Web API based project, I have a middleware which is being executed for every request. I want to avoid this situation and want it to only execute for those API controllers which ...
-2
votes
1
answer
83
views
Cannot access a disposed object in Entity Framework
I am creating a middleware to store all incoming API request and response body along with some other data, I am using Entity Framework as my ORM.
It's working well, but in some request and response ...
0
votes
0
answers
60
views
How to create middleware API in .NET Core
I need to write a middleware micro service API from another website which is SSL secured; I need to load the certificate and wait for any post calls on that url and catch the data in my end. I have ...
0
votes
1
answer
184
views
Access denied when adding rule to Windows firewall (INetFwPolicy2) with C# from Core Middleware program
I'm trying to add a rule to Windows firewall in .Net Core Middleware (httpHandler) written in C# . The code looks like this:
INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type....
1
vote
1
answer
253
views
Modifying `Request.Path` via middleware in an ASP.NET Core Web API project does not change the controller/action used
I have a small sandbox application based on the ASP.NET Core Web API template where I am attempting to modify the controller/action to be used based on a custom header and to facilitate this I am ...
-1
votes
2
answers
407
views
Why a middleware does not get executed if applied after app.UseEndpoints() in ASP.NET Core Web APIs
I am trying to create a middleware that should execute after the execution of endpoint. But when I add middleware in after the app.UseEndPoints(), it never gets invoked, however it is invoked if ...
0
votes
0
answers
97
views
C# Asp.Net Core Middleware - Page Loading Time
I have implemented a middleware class that determines the elapsed time that a page took to load.
public sealed class PageLoadTimeMiddleware
{
private readonly RequestDelegate _next;
...
0
votes
1
answer
102
views
Create Ocelot middleware in c#
Net core. I am trying to implement Authorization in Ocelot gateway but due to some oprn issues at ocelot side i am looking at alternatives mentioned at https://github.com/ThreeMammals/Ocelot/issues/...
0
votes
0
answers
58
views
ASP.NET Core Middleware - redirect happens before code for changing headers is executed
I have written a middleware that supposed to cache a specific endpoint redirect (302) and add parameters to it's query string.
This is my middleware code:
public class ...
0
votes
1
answer
523
views
Redirect to login from .NET Core auth middleware
I have an ASP.NET Core 8 MVC app, and I'm using auth middleware to authenticate and ensure that an access token (JWT) resides in the cookies.
Working to make sure that when an action with an [...