Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
135 views

I was recently in a technical discussion with a senior developer and was asked: What is the difference between RequestDelegate and Middleware in ASP.NET Core? I have already visited the following ...
phougatv's user avatar
  • 1,060
0 votes
1 answer
151 views

I am trying to implement a custom middleware to globally handle exceptions in my ASP.NET Core Web API project. My .NET Core version is 9.0. I created a custom class by extending from IMiddleware. My ...
Prabir Choudhury's user avatar
0 votes
1 answer
185 views

We have a Durable Function with multiple orchestrators and activities. We would like to use a middleware as global exception handler instead of handling it in every orchestrator/activity. We can catch ...
mburm's user avatar
  • 1,525
0 votes
1 answer
350 views

In ASP .NET Core app want to make one of my controllers sessionless. So I do the following: app.UseWhen( context => context.GetRouteValue("controller") is not "SomeValue", app =&...
Slepoyi's user avatar
  • 453
0 votes
1 answer
620 views

I needed a custom file provider, and to access a request's HttpContext, I found a solution using IHttpContextAccessor: app.UseWhen(ctx => ctx.Request.Path.StartsWithSegments("/res", ...
Asons's user avatar
  • 87.7k
0 votes
1 answer
164 views

I need to allow for individual hosts to have their own folder serving static files. Started out doing like this: var hosts = cfg.GetSection("AppSettings:AvailableHosts").Get<string[]>()...
Asons's user avatar
  • 87.7k
2 votes
1 answer
118 views

Whenever I send a POST request to my server from a frontend webpage I've made, the DevTools console throws the error below: Access to fetch at 'http://127.0.0.1:5000/CreateBooking' from origin 'http:/...
Bansdns's user avatar
  • 25
1 vote
1 answer
151 views

I use the following to create an instance of a class for storing user information during the request: services.AddScoped<IUserSettings, UserSettings>(); Then I use middleware to set the values ...
mtl's user avatar
  • 43
0 votes
1 answer
93 views

I am using semaphore to handle one request at a time and enqueue other request and process in sequence. But when I run the code it run first request and drop other request. What I am doing wrong here?...
Alamzaib Farooq's user avatar
0 votes
1 answer
100 views

I want to read the Body of incoming requests with the help of my HttpRequestTelemetryInitializer class. Although my GetRequestHeader method works successfully, I get the following error on the var ...
Mehmet Serkan Ekinci's user avatar
0 votes
0 answers
74 views

I am trying to configure a global error handler for my web app. Configuration In the Startup.cs Configure method: if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app....
Ryan's user avatar
  • 682
0 votes
1 answer
83 views

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,...
Terry's user avatar
  • 2,028
-1 votes
1 answer
61 views

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....
Onur's user avatar
  • 1
0 votes
1 answer
1k views

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: ...
Abdullah Sameer's user avatar
0 votes
1 answer
548 views

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 &...
Ian Horwill's user avatar
  • 3,017
0 votes
1 answer
413 views

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 ...
tariq's user avatar
  • 109
0 votes
0 answers
158 views

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 ...
Shahzad's user avatar
-2 votes
1 answer
143 views

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 ...
Shakeeb Kp's user avatar
0 votes
0 answers
69 views

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 ...
Nikola's user avatar
  • 1
0 votes
1 answer
694 views

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....
Velocedge's user avatar
  • 1,504
2 votes
1 answer
691 views

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 ...
Gabriel Read's user avatar
-1 votes
1 answer
1k views

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 ...
rf_khan's user avatar
0 votes
0 answers
232 views

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; ...
Goober's user avatar
  • 13.5k
0 votes
1 answer
188 views

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/...
Niranjan's user avatar
  • 351
0 votes
0 answers
95 views

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 ...
developer82's user avatar
  • 13.8k
0 votes
1 answer
1k views

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 [...
coach_rob's user avatar
  • 891
0 votes
2 answers
193 views

I created a new Asp.Net WebApi project just to experiment, and I added a new inline middleware as in the documentation. The application starts, but when calling the action from Swagger I get a result ...
Daniele Armanasco's user avatar
1 vote
1 answer
910 views

I have implemented a custom middleware in my ASP.NET Core application to log HTTP request metrics using Prometheus. I implemented the middleware using the link. However, despite the middleware being ...
Ammar's user avatar
  • 43
0 votes
0 answers
299 views

I'm working on an ASP.NET Core application where I have a default route template, for example: ~/api/{area}/[controller]/{action?}/{id?}. My goal is to match incoming URLs with other route templates ...
Emre Kabaoglu's user avatar
0 votes
2 answers
183 views

I want to make multiple implementations of a specific interface accessible through an Abstract Factory in .NET Core. Based on a supplied enum the correct implementation should be returned. This is my ...
Engin Şengül's user avatar
0 votes
1 answer
166 views

Using Nopcommerce V.4.5 Whenever there is a 404 error it redirect to /pagenotfound. I am trying for it to show the same View on the original URL that was 404. So far: I have added a custom middleware ...
confusedMind's user avatar
  • 2,663
0 votes
1 answer
109 views

I saw the following code: class ReaderMiddleware { IReader reader; public ReaderMiddleware(RequestDelegate _, IReader reader) => this.reader = reader; public async Task ...
Anthony Voronkov's user avatar
3 votes
1 answer
471 views

C# aspnet webapp, I have the following constructor in my middleware: public MiddlewareCustomRuntimeExceptionHandler (RequestDelegate next, ILogger<MiddlewareCustomRuntimeExceptionHandler> ...
Tapani Talvitie's user avatar
0 votes
0 answers
55 views

Consider this client request: var content = new MultipartFormDataContent(); var stream = new FileStream("c:\10GB.zip", FileMode.Open, FileAccess.Read); content.Add(new StreamContent(stream), ...
Jonas Rembratt's user avatar
1 vote
1 answer
1k views

I'm working on an ASP.NET code base that uses sessions, authentication, and authorization. They are initialized in the following order: app.UseSession(); app.UseAuthentication(); app.UseAuthorization()...
micka190's user avatar
  • 1,013
0 votes
0 answers
165 views

I have a scenario where I want to check a feature flag per request. The way I have implemented this so far is I use middleware.. public class SalesFeatureMiddleware { private readonly ...
Dr Schizo's user avatar
  • 4,478
0 votes
1 answer
322 views

At the time of high user traffic, the server struggles to keep up with the user requests, which causes the users to refresh the page one or more time. This causes the cancelled tasks to pile up in the ...
Muhammad Usama's user avatar
0 votes
1 answer
1k views

I have an ASP.NET Core web application in which I have a pipeline of several custom middleware functions. I'm trying to add a new one to the beginning of the pipeline that short-circuits the rest of ...
Ryan's user avatar
  • 7,997
3 votes
3 answers
3k views

I'm trying to modify the response headers in some middleware after it has finished in the controller, but I'm getting an error message: System.InvalidOperationException: Headers are read-only, ...
Q-bertsuit's user avatar
  • 3,467
0 votes
1 answer
758 views

I use the event OnAuthenticationFailed in JWTBearer only to handle the response when the token expires. Here's the code: services.AddAuthentication(x => { x.DefaultAuthenticateScheme = ...
Maskliv's user avatar
0 votes
1 answer
771 views

I need to filter some of our API actions to work only from local host. Seems there are a few methods to accomplish this: setup CORS; Add an Authorization filter or an Action filter; Add a middleware ...
Kasbolat Kumakhov's user avatar
1 vote
1 answer
103 views

i have a dotnet core 6 api with a very strange behaviour in exception handling there's an exception middleware that should handle all exception in api calls (which is correctly instantiated in app ...
p.desterlich's user avatar
1 vote
1 answer
429 views

I have a React app that uses a .NET 7 API. We are using Graylog for logging. The idea is to provide an API endpoint for the react app to POST its error logs. I want to use a different log source if ...
Junaid's user avatar
  • 1,020
0 votes
1 answer
554 views

I am migrating the asp.net web application to asp.net core 6.0. For handling inbound proxies i have followed the following Microsoft link; https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/...
user1263981's user avatar
  • 3,157
0 votes
1 answer
545 views

I have an ASP.NET Core application with a custom middleware designed to replace some external CDN links. The middleware correctly updates the response body with the new data, but keeps appending it to ...
Dezzamondo's user avatar
  • 2,338
0 votes
1 answer
2k views

I have created a custom middleware and added a statements before and after the await next(context) method call. If there is no middleware after my custom middleware, then the statements after next(...
Ambareesh's user avatar
0 votes
1 answer
795 views

I use a middleware for an HttpClient. I use one instance of HttpClient as a singleton (we don't use DI, otherwise an HttpClientFactory would be a better option). My question: Is it possible to set a ...
arsenii41.2hz's user avatar
0 votes
0 answers
315 views

I have an ASP.NET Core 6.0 Web API. One of the middleware catches an exception and translates it to a user-friendly error message as response. This is existing web API and multiple middleware are ...
user9297554's user avatar
0 votes
1 answer
487 views

I am working on an ASP.NET Core 6 MVC project and trying to implement global error handling for web pages. Currently, the code is local on my laptop with Windows 11, Visual Studio 2022 and using ...
bedrock's user avatar
  • 706
0 votes
1 answer
112 views

I have used two Map methods one after other in Startup class in a demo ASP.NET Core 5.0 Empty project. I know that Map method is used to branch the middleware pipeline. As per the pathMatch string, ...
AppliedK's user avatar

1
2 3 4 5
9