dotnet / dotnet/aspnetcore

Add HttpContext.Endpoint property

Open
#50,522 6 comments 3 reactions 0 assignees View on GitHub
api-approved area-networking help wanted
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

ASP.NET Core includes the [GetEndpoint and SetEndpoint extension methods](https://github.com/dotnet/aspnetcore/blob/00d0038f937f0059a847fde504649fe33ec935e0/src/Http/Http.Abstractions/src/Routing/EndpointHttpContextExtensions.cs#L13-L56) for working with endpoints and HttpContext.

I think endpoints have become such an intrinsic feature to ASP.NET Core that we should consider making it a real property on `HttpContext`. A property would be easier to use (no need to have the right namespace for the extension method) and feel better to use compared to a method.

### Describe the solution you'd like

Add `HttpContext.Endpoint` property.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with src/Http/Http.Abstractions/src/Routing/EndpointHttpContextExtensions.cs and inspect GetEndpoint and SetEndpoint, then trace the HttpContext API they extend. Done means HttpContext exposes an Endpoint property with the endpoint access currently provided by those extensions, with behavior verified by the relevant project tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.