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