How can I find the sender’s IP address from an HTTP request?

0
15
Asked By TechieNinja42 On

I'm working with HTTP requests using an HttpListener and I need to log the IP address of the sender. I've tried searching online, but I'm getting a mix of methods that don't seem to fit my situation. Any advice would be much appreciated!

3 Answers

Answered By DevWizard77 On

In your case, the sender's IP might be part of the server variables. You can refer to the documentation for the HttpRequest class in .NET to find relevant properties that could include the IP address you're looking for.

Answered By CodeExplorer99 On

One straightforward way to get the sender's IP address is to check the RemoteAddr header. I'm not sure how it's done specifically in PowerShell, but if you're using a reverse proxy like Cloudflare, they have detailed instructions on how to access it as well. If you're running an nginx server, there's a way to configure that too.

Answered By CuriousCoder88 On

It sounds like you're using the Http Listener, but that's pretty broad. Can you clarify what exact version or commands you are employing? There are a few different implementations, and that could change how you access the IP address.

TechieNinja42 -

Thanks for your reply! I'm using a more recent version of PowerShell, but I don't have a specific command at hand. Any suggestions?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.