zoukankan      html  css  js  c++  java
  • .NET 关于取当前地址的问题

    用Request.CurrentExecutionFilePath,就只能取到www.5ixznr.cn/index.aspx

    用Request.RawUrl就可以把index.aspx??boardid=22&page=1全取出来  

    在ASP.NET编程中经常需要用Request获取url的有关信息,Request中有多种方法获取url信息.测试的url地址是http://www.test.com/testweb/default.aspx?xx=xx, 结果如下:


    Request.ApplicationPath: /testweb
    Request.CurrentExecutionFilePath: /testweb/default.aspx
    Request.FilePath: /testweb/default.aspx
    Request.Path: /testweb/default.aspx
    Request.PathInfo:
    Request.PhysicalApplicationPath: E:\WWW\testweb\
    Request.PhysicalPath: E:\WWW\testweb\default.aspx
    Request.RawUrl: /testweb/default.aspx?xx=xx
    Request.Url.AbsolutePath: /testweb/default.aspx
    Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
    Request.Url.Host: www.test.com
    Request.Url.LocalPath: /testweb/default.aspx  

    //---------------------------以下代码未测试------------------

    private string GetCurrentQueryParams()
    {
    StringBuilder stringBuilder = new StringBuilder();
    string currentPath = HttpContext.Current.Request.Url.PathAndQuery;
    int startIndex = currentPath.IndexOf("?");
    if (startIndex <= 0)
    return string.Empty;
    string[] nameValues = currentPath.Substring(startIndex + 1).Split('&');
    foreach ( string param in nameValues )
    {
    stringBuilder.Append( param );
    stringBuilder.Append( "&" );
    }
    return stringBuilder.ToString().TrimEnd( '&' );
    }

  • 相关阅读:
    redis
    libevent简述
    IPC-本地套接字
    广播和组播
    UDP实现并发服务器
    select
    epoll
    BUUCTF-[极客大挑战 2019]HardSQL 1
    CTFHUB-Injection V2.0
    SQL注入中登录框只验证用户名情况下的绕过
  • 原文地址:https://www.cnblogs.com/Byrd/p/2455233.html
Copyright © 2011-2022 走看看