url问题

relax_xi 2010-11-15 01:36:36
我将http://localhost:51146/Default.aspx改为http://127.0.0.1:51146/Default.aspx为什么base.Request.Url.Host获取的还是localhost,我调试的是根据url根的不同做不同的逻辑 ,127.0.0.1不行 还可以根据什么ip来调试/
...全文
191 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
relax_xi 2010-11-15
  • 打赏
  • 举报
回复
这问题有救吗
relax_xi 2010-11-15
  • 打赏
  • 举报
回复
修改了C:\WINDOWS\system32\drivers\etc\hosts还是不行 获取的还是localhost
lilianjie0426 2010-11-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 relax_xi 的回复:]

C# code
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entr……
[/Quote]

#    127.0.0.1       localhost
前面的#去掉试试。。。
relax_xi 2010-11-15
  • 打赏
  • 举报
回复
我需要的就是base.Request.Url.Host获取的值 本机调试 只能获取到localhost 能不能用base.Request.Url.Host获取到localhost 以外的值
xinshouno7 2010-11-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 q107770540 的回复:]
C:\WINDOWS\system32\drivers\etc\hosts
localhost 127.0.0.1
[/Quote]
你指的跟路径我可以理解为
Request.ServerVariables[ "APPL_PHYSICAL_PATH" ]获取这个吗?
relax_xi 2010-11-15
  • 打赏
  • 举报
回复
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

# 127.0.0.1 localhost
# ::1 localhost
把这两个修改了是吗
relax_xi 2010-11-15
  • 打赏
  • 举报
回复
我要获取的是 根url (127.0.0.1或者localhost)
q107770540 2010-11-15
  • 打赏
  • 举报
回复
C:\WINDOWS\system32\drivers\etc\hosts
localhost 127.0.0.1
fellowcheng 2010-11-15
  • 打赏
  • 举报
回复
Request.Url.GetLeftPart的应用:

//发送按钮

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default3.aspx?id=10&name=aa">HyperLink</asp:HyperLink>

//接收页面

string baseUrl = "Path:" + Request.Url.GetLeftPart(UriPartial.Path) + "<br>|" + "Authority:" + Request.Url.GetLeftPart(UriPartial.Authority) + "<br>|" + "Query:" + Request.Url.GetLeftPart(UriPartial.Query) + "<br>|" + "Scheme:" + Request.Url.GetLeftPart(UriPartial.Scheme);

Response.Write(baseUrl);

//显示结果

Path:http://localhost:1061/WebSite1/Default3.aspx
|Authority:http://localhost:1061
|Query:http://localhost:1061/WebSite1/Default3.aspx?id=10&name=aa
|Scheme:http://

62,272

社区成员

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

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

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

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