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里测了一下,没有变化

  • 相关阅读:
    2021NUAA暑假集训 Day3 题解
    2021NUAA暑假集训 Day2 题解
    2021NUAA暑期模拟赛部分题解
    CodeForces 1038D Slime
    UVA 11149 Power of Matrix
    UVA 10655 Contemplation! Algebra
    UVA 10689 Yet another Number Sequence
    HDU 4549 M斐波那契数列
    HDU 4990 Reading comprehension
    CodeForces 450B Jzzhu and Sequences
  • 原文地址:https://www.cnblogs.com/jams742003/p/1659713.html
Copyright © 2011-2022 走看看