Request获取url信息

简介: 在ASP.NET编程中经常需要用Request获取url的有关信息,Request中有多种方法获取url信息 连转再载再测如下:    (一)页面Test.aspx protected void Page_Load(object sender, EventArgs e) {     Response.

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

 

博客园大道至简

http://www.cnblogs.com/jams742003/

转载请注明:博客园

目录
相关文章
|
2月前
|
机器学习/深度学习 前端开发 JavaScript
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
43 0
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
|
6月前
|
缓存 前端开发 JavaScript
【前端用法】jquery获取当前页面的URL信息
【前端用法】jquery获取当前页面的URL信息
51 0
|
4月前
|
Web App开发 人工智能 测试技术
软件测试/人工智能|解决Selenium中的异常问题:“error sending request for url”
软件测试/人工智能|解决Selenium中的异常问题:“error sending request for url”
52 0
|
4月前
|
JSON 数据格式
这个错误信息表示在执行`requests.post(url, data=data, headers=head).json()`时出现了问题
这个错误信息表示在执行`requests.post(url, data=data, headers=head).json()`时出现了问题
37 2
|
Python
Python实战:使用re正则库匹配url中的id信息
Python实战:使用re正则库匹配url中的id信息
172 0
|
JavaScript 前端开发
JavaScript 获取当前URL信息
JavaScript 获取当前URL信息
73 0
|
资源调度 小程序
03导航链接的制作(wx:for循环)和小程序警告request fail url not in domain list
03导航链接的制作(wx:for循环)和小程序警告request fail url not in domain list
Request mapping url and handler registration
Request mapping url and handler registration
104 0
Request mapping url and handler registration