protected string GetUrl()
{
//取本页URL地址
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;
}

return strTemp;
}
string myurl = GetUrl();

 

好像有一个小Bug;如当前URL为http:www.163.com/001.aspx

返回的是: http:www.163.com/001.aspx?

 

一般来说,在当前页面跳转的话,最好使用这个:

protected string GetUrl()
{
//取本页URL地址
string strTemp="";

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

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

return strTemp;
}
string myurl = GetUrl();

去年前面的网站域名,

 

转帖自: http://blog.csdn.net/szynet/archive/2008/04/11/2282629.aspx

相关文章:

  • 2021-11-05
  • 2021-05-27
  • 2022-12-23
  • 2021-08-10
  • 2021-11-23
  • 2021-11-23
  • 2022-12-23
猜你喜欢
  • 2021-10-09
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
相关资源
相似解决方案