怎么获取URL

huangyugan 2010-03-01 03:48:27
例如地址栏中的是http://www.163.com

有办法获取地址栏的URL“http://www.163.com”吗?

求C#写法
...全文
61 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
asdfg_ 2010-03-01
  • 打赏
  • 举报
回复
string strTemp="";
if(Request.ServerVariables["HTTPS"] == "off")
{
strTemp = "http://";
}
else
{
strTemp = "https://";
}

strTemp = strTemp + Request.ServerVariables["SERVER_NAME"];

if(Request.ServerVariables["SERVER_PORT"] != "80")
{
strTemp = strTemp + ":" + Request.ServerVariables["SERVER_PORT"];
}

strTemp = strTemp + Request.ServerVariables["URL"];

if(Request.QueryString != null)
{
strTemp = strTemp + "?" + Request.QueryString;
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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