using System;
Using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
Summary description of the
namespace WebApplication5
{
///<summary>
///WebForm1.
///</summary>
public class WebForm1:System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load (object sender, System.EventArgs e)
{
// Place user code here to initialize page
string strhostip= "";
iphostentry Oiphost=dns.resolve (environment.machinename);
if (oIPHost.AddressList.Length >0)
strhostip=oiphost.addresslist[0]. ToString ();
this. Textbox1.text=strhostip;
}
Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}
}
trackback:http://tb.blog.csdn.net/trackback.aspx?postid=762769
[Click here to collect this article] posted on May 30, 2006 09:41:00
Kwanhong published in 2006-06-02 11:01:00 ip:211.162.74.*
Using System.Net;
Iphostentry localhost =
Dns.gethostentry (Dns.gethostname ());
IPAddress address = localhost. ADDRESSLIST[0];
Console.WriteLine (Address.tostring ());