zoukankan      html  css  js  c++  java
  • Request获取url信息

    在ASP.NET编程中经常需要用Request获取url的有关信息,Request中有多种方法获取url信息

    连转再载再测如下: 

    (一)页面Test.aspx

    protected void Page_Load(object sender, EventArgs e)

    {

        Response.Write("Request.ApplicationPath" + Request.ApplicationPath + "<br/>");

        Response.Write("Request.CurrentExecutionFilePath" + Request.CurrentExecutionFilePath + "<br/>");

        Response.Write("Request.Path" + Request.Path + "<br/>");

        Response.Write("Request.PathInfo" + Request.PathInfo + "<br/>");

        Response.Write("Request.PhysicalApplicationPath" + Request.PhysicalApplicationPath + "<br/>");

        Response.Write("Request.PhysicalPath" + Request.PhysicalPath + "<br/>");

        Response.Write("Request.RawUrl" + Request.RawUrl + "<br/>");

        Response.Write("Request.Url.AbsolutePath" + Request.Url.AbsolutePath + "<br/>");

        Response.Write("Request.Url.AbsoluteUri" + Request.Url.AbsoluteUri + "<br/>");

        Response.Write("Request.Url.Host" + Request.Url.Host + "<br/>");

    Response.Write("Request.Url.LocalPath" + Request.Url.LocalPath + "<br/>");

     

    if (Request.UrlReferrer != null)

                Response.Write("上一页的地址:" + Request.UrlReferrer.AbsolutePath);

    //UrlReferrer:获取有关客户端上次请求的 URL 的信息,该请求链接到当前的 URL

     

    }

     

    (二)页面a.aspx

    在页面a.aspx中添加对Test.aspx的链接

    <a href="Test.aspx" target="_self">点击</a>

     

    (三)访问a.aspx,并点击链接

     

    结果:

     

    Request.ApplicationPath/web2
    Request.CurrentExecutionFilePath
    /web2/Test.aspx
    Request.Path
    /web2/Test.aspx
    Request.PathInfo

    Request.PhysicalApplicationPath
    E:\test8\Net35\web2\
    Request.PhysicalPath
    E:\test8\Net35\web2\Test.aspx
    Request.RawUrl
    /web2/Test.aspx
    Request.Url.AbsolutePath
    /web2/Test.aspx
    Request.Url.AbsoluteUri
    http://localhost:20372/web2/Test.aspx
    Request.Url.Host
    localhost
    Request.Url.LocalPath
    /web2/Test.aspx
    上一页的地址:/web2/la1.aspx

     

    iframe里测了一下,没有变化

  • 相关阅读:
    Nginx 日志格式配置介绍
    Java Spring cron表达式使用详解
    Elasticsearch Query DSL
    Elasticsearch Search APIs
    网易2016研发工程师编程题:小易的升级之路
    2016奇虎360研发工程师内推笔试编程题:找镇长
    2016奇虎360研发工程师内推笔试编程题:找到字符串第一个只出现一次的字符
    lintcode: 最长无重复字符的子串
    lintcode :同构字符串
    lintcode : 跳跃游戏
  • 原文地址:https://www.cnblogs.com/jams742003/p/1659713.html
Copyright © 2011-2022 走看看