==> [FrmRequestUserHostAddress.aspx] 소스 및 디자인

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmRequestUserHostAddress.aspx.cs" Inherits="FrmRequestUserHostAddress" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

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

<head runat="server">

    <title></title>

</head>

<body>

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

    <div>

   

        현재 접속자의 IP주소 얻기<br />

        <br />

        <asp:Label ID="Label1" runat="server"></asp:Label>

        <br />

        <asp:Label ID="Label2" runat="server"></asp:Label>

        <br />

        <asp:Label ID="Label3" runat="server"></asp:Label>

   

    </div>

    </form>

</body>

</html>

 




 

-------------------------------------------------------------------------------------

 


==> [FrmRequestUserHostAddress.aspx.cs] 소스


 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

        //현재 접속자의 IP주소를 얻는 3가지 방법

        this.Label1.Text = Request.UserHostAddress;

 

        Label2.Text = Request.ServerVariables["REMOTE_HOST"];

        Label3.Text = Request.ServerVariables["REMOTE_ADDR"];

    }

}

 

 

-------------------------------------------------------------------------------------

 


[실행결과]






Posted by holland14
: