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

  • 相关阅读:
    python全栈开发day54-mysql库操作、表操作、数据类型、完整性约束
    CentOS7.5安装nodejs 转
    python全栈开发day53-mysql
    python全栈开发day52-bootstrap的运用
    python全栈开发day51-jquery插件、@media媒体查询、移动端单位、Bootstrap框架
    机器学习之交叉验证和网格搜索
    机器学习之混淆矩阵
    机器学习之朴素贝叶斯算法
    机器学习之TF-IDF
    机器学习之K-近邻算法
  • 原文地址:https://www.cnblogs.com/jams742003/p/1659713.html
Copyright © 2020-2023  润新知