2014-05-04 271 views
-2

我正在使用ASP.NET webforms,並且希望獲取訪問我的網站的客戶端的IP地址和MAC地址。 這可能嗎?獲取客戶端的MAC地址和IP地址訪問我的網站

+0

爲什麼你需要MAC地址? –

+0

要存儲在數據庫中,所以我可以注意不會有雙重投票被註冊。 –

+0

@AdamB:存儲IP地址不會幫助您做到這一點。個人可以擁有很多知識產權,整個國家可以共享知識產權。 – SLaks

回答

0

您可以從Request.UserHostAddress獲取IP地址。

您無法獲取MAC地址。

0

您可以使用Request.UserHostAddress或Request.ServerVariables [「REMOTE_ADDR」]獲取IP地址。如果客戶端位於代理服務器之後,那麼您可以嘗試使用ServerVariables [「HTTP_X_FORWARDED_FOR」]獲取他的IP。閱讀here瞭解更多詳情。

除非客戶端與服務器在同一個物理子網上,否則無法獲取MAC地址。獲得內部網絡中的MAC地址

//get all nics 
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); 
//display the physical address of the first nic in the array, 
//which should correspond to our mac address 
Label1.Text = nics[0].GetPhysicalAddress().ToString(); 

或閱讀更多here