ASP.NET ve SQL’de IP adresi getirme

Bulunduğunuz server’un ip adresini getiren asp.net kodu

string strHostName = System.Net.Dns.GetHostName();
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];

Bulunduğunuz server’un ip adresini getiren sqlkodu

DECLARE @IP_Address varchar(255)
SELECT @IP_Address = client_net_address FROM sys.dm_exec_connections
WHERE Session_id = @@SPID

print(@IP_Address)

Leave a Reply

Your email address will not be published. Required fields are marked *