zoukankan      html  css  js  c++  java
  • C#获取当前IE地址栏的url[转帖]

    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

  • 相关阅读:
    Leetcode 127 **
    Leetcode 145
    Leetcode 144
    Leetcode 137
    Leetcode 136
    重写nyoj2——括号匹配
    堆排序
    Leetcode 150
    【转】个人最常用的Eclipse快捷键
    Ajax编程中,经常要能动态的改变界面元素的样式
  • 原文地址:https://www.cnblogs.com/liangwei389/p/1175965.html
Copyright © 2011-2022 走看看