Kullanıcı IP sini Öğrenmek

 

Merhaba arkadaşlar bu makalemizde basit bir kod parçacığıyla kullanıcılara ait ip adresini öğreneceğiz.



 




Şekil 1

 

WebForm1.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace get_users_ip_address

{

    public partial class WebForm1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            string IPAdd = string.Empty;

            IPAdd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(IPAdd))

                IPAdd = Request.ServerVariables["REMOTE_ADDR"];

            lblIP.Text = IPAdd;

 

        }

    }

}

 

WebForm1.aspx

     

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="get_users_ip_address.WebForm1" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

        <div>

            <p style="font-size:xx-large"><b>Your IP Address (Ip Adresiniz ) : </b></p>

            <asp:Label ID="lblIP" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" ForeColor="#0099FF" Text="Label"></asp:Label>

        </div>

    </form>

</body>

</html>

 

 

Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN

About Bahadır Şahin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Öne Çıkan Yayın

GridView da Seçili Satırı DetailsView da Göstermek

Merhaba arkadaşlar bu makalemizde GridView nesnesi ile birlikte DetailsView nesanesini birlikte kullanacağız. GridView da seçili satırın de...