Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapMiddleware extensions are missing in new Endpoint. #14514

Open
pavinan opened this issue Sep 27, 2019 · 4 comments
Open

MapMiddleware extensions are missing in new Endpoint. #14514

pavinan opened this issue Sep 27, 2019 · 4 comments
Labels
affected-very-few This issue impacts very few customers api-suggestion Early API idea and discussion, it is NOT ready for implementation area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing severity-minor This label is used by an internal tool
Milestone

Comments

@pavinan
Copy link
Contributor

pavinan commented Sep 27, 2019

MapMiddleware extensions are missing in new Endpoint.

In previous routebuilder it has MapMiddlewareRoute, MapMiddlewareGet, MapMiddlewarePost, MapMiddlewarePut, MapMiddlewareDelete.

I have considered the following alternative.

app.UseEndpoints(endpoints =>
{
    var newAppbuilder = endpoints.CreateApplicationBuilder();
    newAppbuilder.UseMiddleware<Middleware1>();

    endpoints.MapGet("middleware1", newAppbuilder.Build());
});
@davidfowl davidfowl added api-suggestion Early API idea and discussion, it is NOT ready for implementation API Review labels Sep 27, 2019
@analogrelay analogrelay added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-middleware labels Oct 1, 2019
@pranavkm pranavkm added this to the 5.0.0-preview1 milestone Oct 2, 2019
@pranavkm
Copy link
Contributor

pranavkm commented Oct 2, 2019

Thanks @pavinan. We'll investigating adding these APIs in the next major release.

@shadow-cs
Copy link

We have come across a similar problem. Previously you could use UseRouter and call UseMvc on both places (while configuring the IRouter ie. in the pipeline branch and on the main app branch). This is however not supported with endpoint routing (as far as I know since calling UseEndpoints on a branched app is not supported).

The way we want to solve this is by using UseWhen which splits the pipeline and rejoins:

app.UseRouting();
app.UseWhen(c => c.Request.Path.StartsWithSegments("/foo"), 
  innerApp => innerApp.UseMiddleware<FooMiddleware>()));
app.UseEndpoints(endpoints => endpoints.MapControllers())'

Is this the right way to go?

As an addition to MapMiddlewareRoute (which branches the pipeline) we would find an analogous UseMiddlewareRoute (if it would rejoin and use the MapControllers from the original branch) useful if such a construct would be possible.

@Tratcher
Copy link
Member

Tratcher commented Feb 26, 2020

@shadow-cs I was able to work around this today as follows:

app.UseEndpoints(endpoints =>
{
    var subApp = app.New();
    subApp.UseMiddleware<FooMiddleware>();
    endpoints.Map("/foo", subApp.Build());
}

Edit: This probably doesn't stack to let you augment existing routes like controllers though.

@mkArtakMSFT
Copy link
Member

We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

@javiercn javiercn added affected-very-few This issue impacts very few customers enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool labels Feb 19, 2021 — with ASP.NET Core Issue Ranking
@rafikiassumani-msft rafikiassumani-msft added area-web-frameworks and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Oct 20, 2021
@captainsafia captainsafia added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-web-frameworks labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-very-few This issue impacts very few customers api-suggestion Early API idea and discussion, it is NOT ready for implementation area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests