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

Need a way to access full HttpContext #171

Closed
jlocans opened this issue Oct 1, 2020 · 2 comments
Closed

Need a way to access full HttpContext #171

jlocans opened this issue Oct 1, 2020 · 2 comments

Comments

@jlocans
Copy link

jlocans commented Oct 1, 2020

First - I think that this is a really great project. Thanks and respect to James.
Sadly, learner about the uncertain future of the project.

Nevertheless, I want to ask for a change, hoping that project continues to live on.

So, I don't really understand why HttpContext in IContextProvider has been stripped down, leaving only ClaimsPrincipal, Headers and RequestUrl. Why not expose the whole object?
This has caused an issue to which I don't see any workaround. I need to access client's IP address which is found in HttpContext.Connection.RemoteIpAddress. Unfortunately this is not available in Function Monkey. This is just one example, I'm sure there are many more cases where one would need to access whole request context object.

@alexeymarkov
Copy link
Contributor

Add services.AddHttpContextAccessor() and you will be able to access the original HttpContext.

@jlocans
Copy link
Author

jlocans commented Nov 4, 2020

Thank you @alexeymarkov !

I'll add what is maybe obvious, but you also need to inject IHttpContextAccessor instead of IContextProvider

@jlocans jlocans closed this as completed Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants