Reading a request Ip address in c# [duplicate] - c#

This question already has answers here:
Request.UserHostAddress issue with return result "::1"
(4 answers)
Closed 9 years ago.
I have a login page where the user can login to my website when the user click on the submit button in the login page I want to read it's Ip address how ca i do this is c# I tried this
Request.UserHostAddress;
but the result was ::1 is it because I am logging in from the local machine or the statement that I used above is wrong?

That's basically the IPv6 version of 127.0.0.1 so is technically correct. If you don't use or need IPv6 disable it in the network adapter settings.

::1 is the IPv6 address, your code is correct.
See this answer for details.

Related

TCP Server disconnect/cable unplugged [duplicate]

This question already has answers here:
Listening for an Ethernet Cable Unplugging Event for a TCP Server Application
(4 answers)
Closed 5 years ago.
I have an application with one server and one client.
How the client will know if the server cable is unplugged or disconnect? Is there event for that?
I don’t want to set a timer to check occasionally if the server gets messages…
And i don't want to use poll...
Thanks,
Elad
Refer at that questions :
Stack overflow 1
StackOverflow 2
Yopu have to analyze the connection status in all the phases and understand in wich phase are the problem, anyway why the connection doesn't works.
There are also other link that refer to your question :
Stack overflow 3
Blog
Last method, work with NetworkChange.NetworkAvailabilityChanged Event
Link : enter link description here

Find out from which url your API called [duplicate]

This question already has an answer here:
Get URL of Referer page in ASP.NET
(1 answer)
Closed 8 years ago.
I'm using web api.My question is: I have to check from where call is coming in Global.asax(Application_AcquireRequestState) because I have to restrict some calls which are coming from unknown urls for the purpose of web api security.
You can use Request.UserHostAddress to get the IP address from which the call is coming and Request.UrlReferrer to get the URL that linked to the current URL.

Specify Custom IP in HTTPWebRequest [duplicate]

This question already has answers here:
how to change originating IP in HttpWebRequest
(2 answers)
Closed 9 years ago.
is it possible to change orginating IP in HTTPWebRequest C# and provide any Custom/fake IP?
You could try out the following Libraries
PCap.NET Referenced from IP address spoofing using PCap.NET
sharppcap Referenced from C# How to spoof IP address for WebRequest

Finding out the Domain Name of an IP Address using C# [duplicate]

This question already has answers here:
How to perform "nslookup host server"
(4 answers)
Closed 9 years ago.
In my application, I should get the domain names of the few IP Addresses I give as Input. I guess this process is called NSLOOKUP. However, I would like to confirm if I'm right. Simple program to implement this and display a MessageBox output is what I look for.
Contributions please...
Thank you in anticipation
IPAddress address = IPAddress.Parse("127.0.0.1");
IPHostEntry entry = Dns.GetHostEntry(address );
Console.WriteLine(entry.HostName);

want to know more about Dynamic Ip [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
what do we mean by dynamic IP ?
and how we can implement a simple example on it using sockets in vb.net ?
thanks all
Read a book about the IP prtocol and the WIndows doucmentation.
Dynamic IP refers to an IP address that is dynamically assigned to a computer when the computer connects to the physical network ,by means of a DHCP server which dynamically configures the host (with a dynamic IP). The opposite is a STATIC IP which is hard-coded into the computer configuration (i.e. you set it statically).
More is in the documentation. This is a low level beginner question - answering it without a lot of context is hard. Books and Documentation provide the context.
A dynamic IP address is assigned from a DHCP server (Dynamic Host Configuration Protocol).
When your network adapter connects to the network, it asks the DHCP server for a lease on an IP address. The DHCP server returns an IP address which has a limited life time. When the lease expires, the network adapter has to ask for a new lease.
The lifetime of a lease is usually something like two hours or 24 hours, whatever is appropriate for the network. A short lifetime for the lease doesn't mean that you change IP address often, because most of the time you will get a lease for the same IP address that you had before.
For a static IP address the DHCP server isn't involved, you simply enter the IP adress in the network settings.
You can't implement dynamic IP addresses using sockets, because you need to have an IP address already to establish a socket connection.

Categories