如何获取应用程序地址(网站地址)

KidAn 2006-10-27 01:01:27
我的Asp.net 地址为:http://localhost/SuperMis/
如何在网站下任意一页面:http://localhost/SuperMis/AA/BB/a.aspx 获得"http://localhost/SuperMis/"这一地址
...全文
558 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujunsummer 2006-11-06
  • 打赏
  • 举报
回复
学习
myminimouse 2006-10-27
  • 打赏
  • 举报
回复
把url处理一下不就好了么
shalen520 2006-10-27
  • 打赏
  • 举报
回复
楼上都说了
C5662601 2006-10-27
  • 打赏
  • 举报
回复
xuexi
bidisty 2006-10-27
  • 打赏
  • 举报
回复
牛人
llzzll 2006-10-27
  • 打赏
  • 举报
回复
string vPath = HttpContext.Current.Request.ApplicationPath;
if ( vPath == "/" )
{
vPath = "";
}
string Port = ":" + HttpContext.Current.Request.Url.Port.ToString();
if ( Port == ":80" )
{
Port = "";
}
string Address = "http://" + HttpContext.Current.Request.Url.Host + Port + vPath + "/";
daishengs 2006-10-27
  • 打赏
  • 举报
回复
从别人的博客中抄的,是谁的,是上面没写。
Request获取url信息的各种方法比较
在ASP.NET编程中经常需要用Request获取url的有关信息,Request中有多种方法获取url信息,但我经常忘了各种方法的具体作用,今天我就写了个测试程序,将各种方法得到的结果列出来,以后用时直接参考一下就行了。
测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:

Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PathInfo:
Request.PhysicalApplicationPath: E:\WWW\testweb\
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
blackhero 2006-10-27
  • 打赏
  • 举报
回复
string strPath= Server.MapPath(this.Request.ApplicationPath + "/" + strTempPath + "/" + "机票预订业务统计" + System.DateTime.Now.ToString("yyyy-MM-dd").ToString() + ".xls");
sunjay117 2006-10-27
  • 打赏
  • 举报
回复
Response.Write("http://"+Request.Url.Host+Request.ApplicationPath);
KidAn 2006-10-27
  • 打赏
  • 举报
回复
我要的是http://localhost/SuperMis/ 网络地址,不是物理地址
sunjay117 2006-10-27
  • 打赏
  • 举报
回复
Server.MapPath("/.")+Request.ApplicationPath

62,243

社区成员

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

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

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

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