asp.net-core-middleware Questions

1

I am attempting to inject SignInManager<ApplicationUser> and AspNetUserManager<ApplicationUser> into my Refresh Token middleware for my WebApi. Just to not I am using Identity, so the m...

2

Solved

I was realizing that I need to write some middleware for httpcontext etc.., but thus I tried to take even an example from Microsoft, and the problem is that even with breakpoints on the outside ......

1

I saw a few articles about IApplicationLifetime and the way I can trigger execution when application starts and stops but I probably miss something because it is just not triggered. Here is my work...
Kwa asked 3/8, 2020 at 14:18

2

Solved

I am trying to add a custom middleware to the pipeline (to be easier I will pick the .NET Core documentation example). Let's say we want to have the Spanish culture set whenever a call to API is fi...
Levorotation asked 13/1, 2020 at 9:5

3

Solved

I am trying to confirm via a unit test that middleware is actually being added to the pipeline. I have the following static method that adds the middleware. This is what I am testing. public stati...
Wigging asked 1/5, 2018 at 12:56

1

Solved

I need to run two middlewares for all my endpoints but the ones under /accounts/*. I use this in ConfigureServices: public void ConfigureServices(IServiceCollection services) { ... services.Add...
Frenzied asked 19/4, 2020 at 17:2

1

Solved

Currently I have app.UseExceptionHandler("/Home/Error"); I want to make the path relative to the original path. For example if Tenant1/PageThatThrowsError then app.UseExceptionHandler("Te...

3

I am trying to use middleware for exception handling in my ASP.Net Core 3.0 Web API project: public class ErrorHandlingMiddleware { private readonly RequestDelegate next; public ErrorHandlingMi...
Feuchtwanger asked 12/11, 2019 at 15:2

1

Solved

When we want to serialize an object to a JSON string in ASP.NET Core's pipeline, we need to work with HttpContext.Response.Body.WriteAsync, unless I'm missing something, as there's no Result proper...
Maladjustment asked 16/3, 2020 at 14:3

1

Solved

How do you unit test custom middleware that inherits from AuthenticationHandler<AuthenticationSchemeOptions>? My custom class that inherits from it is for Basic authentication. public clas...

3

Solved

I'm trying to write some middleware and need to know if the current action method (if any) has a particular filter attribute, so I can change behaviour based it's existence. So is it possible to g...

1

Solved

I'm using ML.NET in an ASP.NET Core application, and I am using the following code in Startup: var builder = services.AddPredictionEnginePool<Foo, Bar>(); if (File.Exists("model.zip")) { b...
Mineraloid asked 27/8, 2019 at 21:18

1

Im trying to make my asp.net core project fully modular. So I grouped some functionalities and separated them in different class libraries. With this structure I can activate/deactivate functionali...
Stinker asked 22/8, 2019 at 21:19

1

My question is basically this -- given the code shown here, what else runs in the pipeline that is trying to start a response to the client? I'm aware of the other questions about that exception, b...
Deguzman asked 18/8, 2019 at 13:28

3

Solved

I am trying to provide an ActiveUser property to Serilog. Unfortunately I cannot seem to find the correct spot to check for the current user. In the below code httpContext.User.Identity.IsAuthenti...

2

Solved

I have two custom ASP.NET Core middlewares: one for authentication (that registers its own authentication scheme) and a second one for some business work. How can I use the authentication middlewa...
Travel asked 11/5, 2018 at 10:55

1

Solved

In a .NET Core Web Application I am using middleware (app.UseMyMiddleware) to add some logging on each request: public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env...
Archerfish asked 9/5, 2019 at 8:22

3

Solved

I want to inject a service based on the HTTP header value. So I have 2 classes - DbDataProvider and InMemDataProvider, both are implemented from IDataProvider. Whenever an API call is made, a heade...
Joliejoliet asked 3/7, 2016 at 21:26

2

Solved

When to use Map and MapWhen branch in asp.net core middleware while we are authenticating request. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Map("", (appBuilde...
Argue asked 27/12, 2017 at 18:41

0

I would like a simple middleware that I can use to combine multiple requests into one request and return the result as a single array response. I don't want to use OData because its too heavy, pl...
Toaster asked 11/12, 2018 at 22:28

3

Solved

I am building up an ASP.Net Core API and I have not been able to find a way to get the connection string from the DBContextOptions. I have the DBContext in my startup.cs as shown below; public vo...

2

Solved

I am trying to inject dependency into my middleware constructor as follows public class CreateCompanyMiddleware { private readonly RequestDelegate _next; private readonly UserManager<Applicat...

3

Solved

I use ASP.NET Core 2.1 and would like to fetch User at a service level. I've seen examples when HttpContextAccessor gets injected into some service and then we fetch the current User via UserManag...
Milli asked 4/8, 2018 at 15:27

1

I am working on a .net core app. I am trying to access route data in a middleware but it always returns null. Here is the controller base route [Route("User/{UserId}/Quote")] public class Quo...
Applejack asked 13/7, 2018 at 0:40

1

Solved

I would like to return only standardized error responses from my Web API (Asp.net Core 2.1), but I can't seem to figure out how to handle model binding errors. The project is just created from the...

© 2022 - 2024 — McMap. All rights reserved.