request获取url的方法总结

辣么多属性、方法  不用就忘了  ,当需要用的时候挠头也想不到,现在总结一下 以备用

例如:http://localhost/testweb/default.aspx

1.Request.ApplicationPath;  获取服务器上ASP.NET应用程序的虚拟应用程序根路径

2.Request.AppRelativeCurrentExecutionFilePath;  获取应用程序根的虚拟路径,使用~使成为相对路径
3. Request.CurrentExecutionFilePath;  获取当前请求的虚拟路径
4.Request.FilePath;    获取当前请求的虚拟路径
5.Request.MapPath("virtualpath"); 将指定虚拟路径映射到物理路径
6.Request.Path;   获取当前请求的虚拟路径
7.Request.PathInfo; 获取具有url扩展名的资源的附加路径信息
8.Request.PhysicalApplicationPath; 获取当前正在执行的服务器应用程序的根目录的物理文件系统路径
9.Request.PhysicalPath; 获取与请求的url相对应的物理文件系统路径
10.Request.RawUrl;获取当前请求的原始url
11.Request.Url  获取当前请求的url

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

12.Request.UrlReferrer 获取客户端上次请求的url信息,该请求连接到当前url

--ServerVariables :获取web服务器变量的集合

foreach (string r in Request.ServerVariables)
                  {
                      Response.Write(r + ">>>" + Request.ServerVariables[r] + "<hr>");
                  }

时间: 2024-07-29 18:46:30

request获取url的方法总结的相关文章

Request获取url各种信息的方法

1.Request获取url各种信息的方法 测试的url地址:http://www.test.com/testweb/default.aspx, 结果如下: Request.ApplicationPath: /testweb Request.CurrentExecutionFilePath: /testweb/default.aspx Request.FilePath: /testweb/default.aspx Request.Path: /testweb/default.aspx Reque

jsp Request获取url信息的各种方法比较

从Request对象中可以获取各种路径信息,以下例子: 假设请求的页面是index.jsp,项目是WebDemo,则在index.jsp中获取有关request对象的各种路径信息如下 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+&q

Request获取请求路径方法介绍

Request对象通过以下方法来获取请求路径. (1)String getServerName():获取服务器名:localhost (2)String getServerPort():获取服务器端口号:8080 (3)String getContextPath():获取项目名:Test (4)String getServletPath():获取Servlet路径:/login (5)String getQueryString():获取参数部门,即问号后面的部分:username=zhangsa

JavaScript获取URL参数方法总汇

现在做页面基本都用AJAX,因此导致操作很麻烦,每次都需要通过JS获取url中的参数值,网上所搜到很多资料,没一次能记住的,也不知道在哪个项目中使用过,现在又需要通过JS获取url参数,因此不能在偷懒了,为了方便自己也得做个资料总汇,不然每次都得找费事费力的,得不偿失.下边就列出老外所有通过JS获取url参数的方法(不断更新): 1.http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery 2.http://

jquery 获取url 参数方法 以及 解决url中文问题

//jQuery 动态给a 标签赋值 跳转 新的页面打开. /* <a class="btn btn-success" id="test" target="_Black" >点击查看列表 >></a> */ 此时需要双层 encodeURI(encodeURI()); $('#test').on('click',function(){ var batch =$('#zhongwen').val(); //获得中

js获取url参数方法

通过下面函数可以返回url参数集合,以对象的形式返回. function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i

HttpServletRequest常用获取URL的方法

1.request.getRequestURL() 返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数.2.request.getRequestURI() 得到的是request URL的部分值,并且web容器没有decode过的 3.request.getContextPath() 返回 the context of the request. 4.request.getServletPath() 返回调用servlet的部分url. 5.reque

request 获取url

1.request.getRequestURL() 返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数.2.request.getRequestURI() 得到的是request URL的部分值,并且web容器没有decode过的 3.request.getContextPath() 返回 the context of the request. 4.request.getServletPath() 返回调用servlet的部分url. 5.reque

JavaScript&amp;jQuery获取url参数方法

JavaScript function getUrlParam(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 var r = window.location.search.substr(1).match(reg); //匹配目标参数 if (r!=null) return unescape(r[2]); return null