C#获取当前IE地址栏的url


Posted on September 9, 2007


protected string GetUrl()
{
    //取本页URL地址
    //2004-3-3 wskyo
    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();
在线学习答案查询入口
微信扫一扫
微信扫码联系