如此这般:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string myurl = GetUrl();
        Response.Write(myurl);
    }
    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.ToString().Trim().Length!=0)
        {
            strTemp = strTemp + "?" + Request.QueryString;
        }

        return strTemp;
    }
}


在js中只要一句:window.location.href
不过要对url做更复杂的分析就不如.net灵活了

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案