为什么用Request.UserHostAddress和Request.UserHostName取得的IP是一样的?

kinglds 2003-01-14 12:08:04
为什么用Request.UserHostAddress和Request.UserHostName取得的IP是一样的?
...全文
242 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kinglds 2003-01-14
  • 打赏
  • 举报
回复
那应该怎么取得机器名,我是在本机运行的。我的机器DNS是192.168.0.1
dotAge 2003-01-14
  • 打赏
  • 举报
回复
如果取不到机器名,那hostName也就返回IP地址
blackcatiii 2003-01-14
  • 打赏
  • 举报
回复
你是在本机运行的吧。
jery_lee 2003-01-14
  • 打赏
  • 举报
回复
你用你自己访问自己当然是一样的了。
dotAge 2003-01-14
  • 打赏
  • 举报
回复
就是用hostName, 但机器名不是任何时候都可以取到的,如果DNS系统没有做反向解析的话。
kinglds 2003-01-14
  • 打赏
  • 举报
回复
各位大哥,有什么办法啊
namespace ioffice { using iOfficeData; using iofficeservice; using Microsoft.VisualBasic; using Microsoft.VisualBasic.CompilerServices; using System; using System.Diagnostics; using System.Resources; using System.Runtime.CompilerServices; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; public partial class login2 : Page { [AccessedThroughProperty("chpwd")] private ImageButton _chpwd; [AccessedThroughProperty("dropBranch")] private DropDownList _dropBranch; [AccessedThroughProperty("frm")] private HtmlForm _frm; [AccessedThroughProperty("help")] private HtmlImage _help; [AccessedThroughProperty("imgLogo")] private HtmlImage _imgLogo; [AccessedThroughProperty("Label1")] private Label _Label1; [AccessedThroughProperty("Label2")] private Label _Label2; [AccessedThroughProperty("Label3")] private Label _Label3; [AccessedThroughProperty("lblLoginID")] private Label _lblLoginID; [AccessedThroughProperty("lblPwd")] private Label _lblPwd; [AccessedThroughProperty("lblSimpleCode")] private Label _lblSimpleCode; [AccessedThroughProperty("login1")] private HtmlImage _login1; [AccessedThroughProperty("login3")] private HtmlImage _login3; [AccessedThroughProperty("ok")] private ImageButton _ok; [AccessedThroughProperty("RequiredFieldValidator1")] private RequiredFieldValidator _RequiredFieldValidator1; [AccessedThroughProperty("txtloginid")] private TextBox _txtloginid; [AccessedThroughProperty("txtpwd")] private TextBox _txtpwd; [AccessedThroughProperty("valSum")] private ValidationSummary _valSum; private HttpCookie cookie; private int i; protected ResourceManager LocRM; public string logintitle; private Mr mr; private iOfficeData.Res Res; private string[] sErrMessage; private iofficeservice.sysSet sysSet; public login2() { base.Init += new EventHandler(this.Page_Init); base.Load += new EventHandler(this.Page_Load); this.mr = new Mr(); this.sysSet = new iofficeservice.sysSet(); this.Res = new iOfficeData.Res(); this.sErrMessage = new string[10]; } private void AccessIni() { this.Session["iSecureLogin"] = 0; this.Session["SerialNumber"] = ""; if (this.mr.InsSession(this.Session.SessionID, this.Request.UserHostAddress) == 1) { this.Response.Redirect("errdog.htm"); } this.imgLogo.Src = StringType.FromObject(this.Application["corplogo"]); //if (DateTime.Compare(DateTime.Today, DateType.FromString("2004-12-20")) >= 0) //{ // Page pgeParent = this; // DbConfig.ShowMessage(ref pgeParent, iOfficeData.Res.GetResource(this.sErrMessage[9], "你的试用期限已到,系统无法启动!请与程序供应商联系!"), "location.replace('http://www.ioffice.cn')", true); //} } private void BindBranch() { this.dropBranch.DataSource = this.mr.GetBranch(0).Tables["branchsel"]; this.dropBranch.DataBind(); } private void chpwd_Click(object sender, ImageClickEventArgs e) { this.UserLogin(1); } private void GotoNext(int iType) { if (iType != 0) { FormsAuthentication.SetAuthCookie(this.txtloginid.Text, false); this.Response.Redirect("chpwd.aspx"); } else { Page page; if (StringType.StrCmp(this.txtpwd.Text, "", false) == 0) { FormsAuthentication.SetAuthCookie(this.txtloginid.Text, false); page = this; DbConfig.ShowMessageAndRedirect(ref page, iOfficeData.Res.GetResource(this.sErrMessage[6], "你的密码为空!为了确保安全,请及时更改你的密码!"), "chpwd.aspx", true); } else { switch (this.mr.NeedIKey()) { case -1: { FormsAuthentication.SetAuthCookie(this.txtloginid.Text, false); string userAgent = this.Request.UserAgent; userAgent = Strings.Mid(userAgent, Strings.InStr(userAgent, "MSIE", CompareMethod.Binary) + 5, 3); if (!Information.IsNumeric(userAgent)) { page = this; DbConfig.ShowMessage(ref page, iOfficeData.Res.GetResource(this.sErrMessage[8], "请选取Microsoft Internet Explorer 6.0或以上版本作为浏览器。否则,将会有部份的iOffice.net功能不能正常使用!"), "/ioffice/default.aspx", true); return; } if (DoubleType.FromString(userAgent) <= 5.0) { page = this; DbConfig.ShowMessage(ref page, iOfficeData.Res.GetResource(this.sErrMessage[7], "你的Microsoft Internet Explorer 版本太低,请及时升级到6.0或以上版本。否则,将会有部份的iOffice.net功能不能正常使用!"), "/ioffice/default.aspx", true); return; } this.Response.Redirect("/ioffice/default.aspx"); return; } case 0: this.Response.Redirect("ikey/userlogin.aspx"); return; case 1: this.Response.Redirect("/ioffice/etoken/useretokenlogin.aspx"); return; } } } } [DebuggerStepThrough] private void InitializeComponent() { } private void LoadIngCookieLoginID() { if (this.Request.Cookies["iofficelogin"] != null) { this.cookie = this.Request.Cookies["iofficelogin"]; this.txtloginid.Text = this.cookie.Values["loginid"]; int num = this.dropBranch.Items.Count - 1; this.i = 0; while (this.i <= num) { if (StringType.StrCmp(this.dropBranch.Items[this.i].Text, this.cookie.Values["branch"], false) == 0) { this.dropBranch.Items[this.i].Selected = true; } this.i++; } this.txtpwd.Text = this.cookie.Values["pwd"]; if (StringType.StrCmp(this.txtpwd.Text, "", false) != 0) { this.cookie.Values["pwd"].Remove(1, this.cookie.Values["pwd"].Length - 1); this.UserLogin(0); } } } private void LocalRes() { ResourceManager manager=null; iOfficeData.Res res = this.Res; if (res.PrepareResource(typeof(login).Assembly, "ioffice.root", ref manager)) { Label lblLoginID = this.lblLoginID; string text = lblLoginID.Text; res.GetResourceEx(ref manager, ref text, "loginid"); lblLoginID.Text = text; lblLoginID = this.lblPwd; text = lblLoginID.Text; res.GetResourceEx(ref manager, ref text, "pwd"); lblLoginID.Text = text; lblLoginID = this.lblSimpleCode; text = lblLoginID.Text; res.GetResourceEx(ref manager, ref text, "simplecode"); lblLoginID.Text = text; res.GetResourceEx(ref manager, ref this.logintitle, "logintitle"); res.GetResourceEx(ref manager, ref this.sErrMessage[1], "sErrMessage1"); res.GetResourceEx(ref manager, ref this.sErrMessage[2], "sErrMessage2"); res.GetResourceEx(ref manager, ref this.sErrMessage[3], "sErrMessage3"); res.GetResourceEx(ref manager, ref this.sErrMessage[4], "sErrMessage4"); res.GetResourceEx(ref manager, ref this.sErrMessage[5], "sErrMessage5"); res.GetResourceEx(ref manager, ref this.sErrMessage[6], "sErrMessage62"); res.GetResourceEx(ref manager, ref this.sErrMessage[7], "sErrMessage7"); res.GetResourceEx(ref manager, ref this.sErrMessage[8], "sErrMessage8"); res.GetResourceEx(ref manager, ref this.sErrMessage[9], "sErrMessage9"); if (res.IsNotSimpChn()) { ImageButton ok = this.ok; text = ok.ImageUrl; res.GetResourceButtonImageURL(ref text); ok.ImageUrl = text; ok = this.chpwd; text = ok.ImageUrl; res.GetResourceButtonImageURL(ref text); ok.ImageUrl = text; HtmlImage help = this.help; text = help.Src; res.GetResourceButtonImageURL(ref text); help.Src = text; help = this.login1; text = help.Src; res.GetResourceButtonImageURL(ref text); help.Src = text; } } res = null; } private void ok_Click(object sender, ImageClickEventArgs e) { this.UserLogin(0); } protected void Page_Init(object sender, EventArgs e) { this.InitializeComponent(); } protected void Page_Load(object sender, EventArgs e) { this.AccessIni(); this.LocalRes(); if (!this.IsPostBack) { this.BindBranch(); this.LoadIngCookieLoginID(); } } private void PwdCookieSet() { this.cookie = new HttpCookie("iofficelogin"); this.cookie.Values.Add("loginid", this.txtloginid.Text); this.cookie.Values.Add("branch", this.dropBranch.SelectedItem.Value); this.cookie.Expires = DateTime.MaxValue; this.Response.AppendCookie(this.cookie); this.cookie = new HttpCookie("iofficeErr"); this.cookie.Values.Add("iofficeneterrset", this.txtpwd.Text + ":ioffice.net"); this.Response.AppendCookie(this.cookie); this.cookie = new HttpCookie("iofficeloginnum"); this.cookie.Values.Add("loginnum", this.mr.GetLoginInf()); //添加 Session["loginnum"] = this.mr.GetLoginInf(); this.Response.AppendCookie(this.cookie); } private void UserLogin(object iType) { int index = this.mr.LoginiOffice(this.sysSet.SafeSql(this.txtloginid.Text), this.txtpwd.Text, this.dropBranch.SelectedItem.Value, this.dropBranch.Visible); if (index == 0) { this.PwdCookieSet(); this.mr.UpLoginInfo(this.Request.UserHostAddress, this.Request.UserHostName); this.sysSet.GetUserStylesSet(); this.GotoNext(IntegerType.FromObject(iType)); } else { Page pgeParent = this; DbConfig.ShowMessage(ref pgeParent, this.sErrMessage[index], "", true); } } protected virtual ImageButton chpwd { get { return this._chpwd; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._chpwd != null) { this._chpwd.Click -= new ImageClickEventHandler(this.chpwd_Click); } this._chpwd = value; if (this._chpwd != null) { this._chpwd.Click += new ImageClickEventHandler(this.chpwd_Click); } } } protected virtual DropDownList dropBranch { get { return this._dropBranch; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._dropBranch != null) { } this._dropBranch = value; if (this._dropBranch != null) { } } } protected virtual HtmlForm frm { get { return this._frm; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._frm != null) { } this._frm = value; if (this._frm != null) { } } } protected virtual HtmlImage help { get { return this._help; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._help != null) { } this._help = value; if (this._help != null) { } } } protected virtual HtmlImage imgLogo { get { return this._imgLogo; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._imgLogo != null) { } this._imgLogo = value; if (this._imgLogo != null) { } } } protected virtual Label Label1 { get { return this._Label1; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._Label1 != null) { } this._Label1 = value; if (this._Label1 != null) { } } } protected virtual Label Label2 { get { return this._Label2; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._Label2 != null) { } this._Label2 = value; if (this._Label2 != null) { } } } protected virtual Label Label3 { get { return this._Label3; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._Label3 != null) { } this._Label3 = value; if (this._Label3 != null) { } } } protected virtual Label lblLoginID { get { return this._lblLoginID; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._lblLoginID != null) { } this._lblLoginID = value; if (this._lblLoginID != null) { } } } protected virtual Label lblPwd { get { return this._lblPwd; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._lblPwd != null) { } this._lblPwd = value; if (this._lblPwd != null) { } } } protected virtual Label lblSimpleCode { get { return this._lblSimpleCode; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._lblSimpleCode != null) { } this._lblSimpleCode = value; if (this._lblSimpleCode != null) { } } } protected virtual HtmlImage login1 { get { return this._login1; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._login1 != null) { } this._login1 = value; if (this._login1 != null) { } } } protected virtual HtmlImage login3 { get { return this._login3; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._login3 != null) { } this._login3 = value; if (this._login3 != null) { } } } protected virtual ImageButton ok { get { return this._ok; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._ok != null) { this._ok.Click -= new ImageClickEventHandler(this.ok_Click); } this._ok = value; if (this._ok != null) { this._ok.Click += new ImageClickEventHandler(this.ok_Click); } } } protected virtual RequiredFieldValidator RequiredFieldValidator1 { get { return this._RequiredFieldValidator1; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._RequiredFieldValidator1 != null) { } this._RequiredFieldValidator1 = value; if (this._RequiredFieldValidator1 != null) { } } } protected virtual TextBox txtloginid { get { return this._txtloginid; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._txtloginid != null) { } this._txtloginid = value; if (this._txtloginid != null) { } } } protected virtual TextBox txtpwd { get { return this._txtpwd; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._txtpwd != null) { } this._txtpwd = value; if (this._txtpwd != null) { } } } protected virtual ValidationSummary valSum { get { return this._valSum; } [MethodImpl(MethodImplOptions.Synchronized)] set { if (this._valSum != null) { } this._valSum = value; if (this._valSum != null) { } } } } }

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧