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

Add HttpRequest.GetUri method #3203

Closed
evil-shrike opened this issue Jun 6, 2018 · 3 comments
Closed

Add HttpRequest.GetUri method #3203

evil-shrike opened this issue Jun 6, 2018 · 3 comments

Comments

@evil-shrike
Copy link
Contributor

There's a helpful extension method: Microsoft.ApplicationInsights.AspNetCore.Extensions.HttpRequestExtensions.GetUri that returns full uri for a given HttpRequest. For some reason these's no such a method in base classes.

But the method is in Microsoft.ApplicationInsights.AspNetCore which starting 2.1 isn't included in metapackage anymore. So usage of the method became not very convenient.

It'd be nice to have such a method somewhere in "Microsoft.AspNetCore.App".

@Tratcher
Copy link
Member

Tratcher commented Jun 6, 2018

You're looking for GetEncodedUrl or GetDisplayUrl.
https://github.com/aspnet/HttpAbstractions/blob/ab0185a0b8d0b7a80a6169fd78a45f00a28e057d/src/Microsoft.AspNetCore.Http.Extensions/UriHelper.cs#L176

Out of curiosity what do you need it for? It's not much good outside of logging.

@evil-shrike
Copy link
Contributor Author

Thanks, but GetEncodedUrl or GetDisplayUrl return strings not Uri.
Besides logging (and putting uri into exceptions) I use Uri.IsLoopback() to detect local requests.

@Tratcher
Copy link
Member

Tratcher commented Jun 7, 2018

See aspnet/HttpAbstractions#536

@Eilon Eilon closed this as completed Jul 13, 2018
ryanbrandenburg pushed a commit that referenced this issue Nov 27, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants