zoukankan      html  css  js  c++  java
  • C#获取页面URL地址

            #region 获取页面地址
            
    /// <summary>
            
    /// 获取页面地址
            
    /// </summary>
            
    /// <returns></returns>
            public static string GetUrl()
            {
                
    //  2009年12月15日 11:45:24
                
    //  B哥 kuibono@163.com
                string strTemp = "";
                
    if (System.Web.HttpContext.Current.Request.ServerVariables["HTTPS"== "off")
                {
                    strTemp 
    = "http://";
                }
                
    else
                {
                    strTemp 
    = "https://";
                }

                strTemp 
    = strTemp + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

                
    if (System.Web.HttpContext.Current.Request.ServerVariables["SERVER_PORT"!= "80")
                {
                    strTemp 
    = strTemp + ":" + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
                }

                strTemp 
    = strTemp + System.Web.HttpContext.Current.Request.ServerVariables["URL"];

                
    if (System.Web.HttpContext.Current.Request.QueryString.AllKeys.Length>0)
                {
                    strTemp 
    = strTemp + "?" + System.Web.HttpContext.Current.Request.QueryString;
                }

                
    return strTemp;
            }
            
    string myurl = GetUrl(); 
            
    #endregion
  • 相关阅读:
    ASP.NET在MVC控制器中获取Form表单值的方法
    MVC中几种常用ActionResult
    EF 配置MySQL
    HTTP 错误 403.6
    26个Jquery使用小技巧(转)
    Win2008R2配置WebDeploy(转)
    IIS快捷方式
    发布你的程序包到Nuget
    PostgreSQL recovery.conf恢复配置
    PostgreSQL 9.5 高可用、负载均衡和复制
  • 原文地址:https://www.cnblogs.com/kuibono/p/1624627.html
Copyright © 2011-2022 走看看