开发者

How do I find the IP address of a web site that is sending data by POST method to an asp.net web page?

EDIT after Answers AND Comments :

How can i find the IP address of a web site (for example bank web site) that is sending to my web site (asp.net page with c#) some specific and needed data by post method?

For example :

<form id="form1" method="post" action="my web site url"></form>

Imagine that I have a user that wants to buy something from my web site!

He/She opens my web site and choose a 开发者_开发百科product and click pay. At this time I can get their ip address by the below answers.

By clicking "pay" I transfer some data such as order_id to a bank web site by a POST method.

When the user goes to the bank website and transfers some money, they then want to get back my web site!

At this time,the bank site sends some data such as transaction_id by a POST method to my web site for checking payment.

For some security reasons and to prevent simulation this transaction_id transfers between the bank site and my web site, I want to check bank ip address when getting his POST data (third party ip address).

For example I want to find the ip-address(mean bank) of transaction_id Sender at below code :

string transaction_id = Page.Request.Form["transaction_id"];  

However, if I check

string ipaddress = HttpContext.Current.Request.UserHostAddress;  

or

Request.ServerVariables("REMOTE_ADDR")

these codes return only that user IP address, not sender of POST data.


 Request.ServerVariables("REMOTE_ADDR")

This link might give more details

http://thepcspy.com/read/getting_the_real_ip_of_your_users/


If you are using 'Socket', then you could just do something like the example:

s.Connect (lep);

// Using the RemoteEndPoint property.
Console.WriteLine ("I am connected to " + IPAddress.Parse (((IPEndPoint)s.RemoteEndPoint).Address.ToString ()) + "on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString ());

// Using the LocalEndPoint property.
Console.WriteLine ("My local IpAddress is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()) + "I am connected on port number " + ((IPEndPoint)s.LocalEndPoint).Port.ToString ());


Can we use the following? Or am I missing something?

string ipaddress = HttpContext.Current.Request.UserHostAddress;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜