转载 ASP.NET中如何取得Request URL的各个部分
转载原地址
http://blog.miniasp.com/post/2008/02/10/How-Do-I-Get-Paths-and-URL-fragments-from-the-HttpRequest-object.aspx
| 網址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc | |
| Request.ApplicationPath | / |
| Request.PhysicalPath | D:\Projects\Solution\web\News\Press\Content.aspx |
| System.IO.Path.GetDirectoryName(Request.PhysicalPath) | D:\Projects\Solution\web\News\Press |
| Request.PhysicalApplicationPath | D:\Projects\Solution\web\ |
| System.IO.Path.GetFileName(Request.PhysicalPath) | Content.aspx |
| Request.CurrentExecutionFilePath | /News/Press/Content.aspx |
| Request.FilePath | /News/Press/Content.aspx |
| Request.Path | /News/Press/Content.aspx/123 |
| Request.RawUrl | /News/Press/Content.aspx/123?id=1 |
| Request.Url.AbsolutePath | /News/Press/Content.aspx/123 |
| Request.Url.AbsoluteUri | http://localhost:1897/News/Press/Content.aspx/123?id=1 |
| Request.Url.Scheme | http |
| Request.Url.Host | localhost |
| Request.Url.Port | 1897 |
| Request.Url.Authority | localhost:1897 |
| Request.Url.LocalPath | /News/Press/Content.aspx/123 |
| Request.PathInfo | /123 |
| Request.Url.PathAndQuery | /News/Press/Content.aspx/123?id=1 |
| Request.Url.Query | ?id=1 |
| Request.Url.Fragment | |
| Request.Url.Segments | / News/ Press/ Content.aspx/ 123 |
以下部分转载出处: http://www.cnblogs.com/aspnetjia/p/5222744.html (http://www.aspnetjia.com)
假设当前页完整地址是:http://www.test.com/aaa/bbb.aspx?id=5&name=kelli
"http://"是协议名
"www.test.com"是域名
"aaa"是站点名
"bbb.aspx"是页面名(文件名)
"id=5&name=kelli"是参数
【1】获取 完整url (协议名+域名+站点名+文件名+参数)
string url=Request.Url.ToString();
url= http://www.test.com/aaa/bbb.aspx?id=5&name=kelli
【2】获取 站点名+页面名+参数:
string url=Request.RawUrl;
(或 string url=Request.Url.PathAndQuery;)
url= /aaa/bbb.aspx?id=5&name=kelli
【3】获取 站点名+页面名:
string url=HttpContext.Current.Request.Url.AbsolutePath;
(或 string url= HttpContext.Current.Request.Path;)
url= aaa/bbb.aspx
【4】获取 域名:
string url=HttpContext.Current.Request.Url.Host;
url= www.test.com
【5】获取 参数:
string url= HttpContext.Current.Request.Url.Query;
url= ?id=5&name=kelli
转载 ASP.NET中如何取得Request URL的各个部分的更多相关文章
- [转载]ASP.NET中TextBox控件设立ReadOnly="true"后台取不到值
原文地址:http://www.cnblogs.com/yxyht/archive/2013/03/02/2939883.html ASP.NET中TextBox控件设置ReadOnly=" ...
- [转载]asp.net中,<%#%>,<%=%>和<%%>分别是什么意思,有什么区别
在asp.net中经常出现包含这种形式<%%>的html代码,总的来说包含下面这样几种格式: 一. <%%> 这种格式实际上就是和asp的用法一样的,只是asp中里面是vbsc ...
- 转载 asp.net中ViewState的用法详解
转载原地址: http://www.jb51.net/article/73662.htm 在web窗体控件设置为runat = "server",这个控件会被附加一个隐藏的属性_V ...
- [转载]ASP.NET中IsPostBack详解
1.IsPostBack介绍Page.IsPostBack是一个标志:当前请求是否第一次打开. 调用方法为:Page.IsPostBack或者IsPostBack或者this.IsPostBack或者 ...
- 转载ASP.net 中 OutputCache 指令各个参数的作用
使用@ OutputCache指令 使用@ OutputCache指令,能够实现对页面输出缓存的一般性需要.@ OutputCache指令在ASP.NET页或者页中包含的用户控件的头部声明.这种方式非 ...
- 转载MSDN 在ASP.NET 中执行 URL 重写
转载文章原网址 http://msdn.microsoft.com/zh-cn/library/ms972974.aspx 摘要:介绍如何使用 Microsoft ASP.NET 执行动态 URL 重 ...
- asp.net中Response对象鱼Request对象
在asp.net中Response与Request对象是两个常用的对象,虽然他们长得有点像,但是作用却是截然不同,我们来看一下他们他们都有哪些不同. 一.Response对象主要作用:像浏览器输出信息 ...
- 解决ASP.NET中的各种乱码问题
解决ASP.NET中的各种乱码问题 阅读目录 开始 页面显示乱码问题 AJAX提交的数据乱码问题 JavaScript中正确的URL编码方式 ASP.NET中正确的URL编码方式 正确的URL编码方式 ...
- iOS中webView加载URL需要处理特殊字符
今天在项目中遇到webView加载URL时,因为URL中有特殊字符,导致页面无法加载,而且在- (BOOL)webView:(UIWebView )webView shouldStartLoadWit ...
随机推荐
- CentOS7.1配置远程桌面
网上看了很多资料,完全是乱的. 我使用的是CentOS7.1的系统.我的要求是windows的客户机可以远程访问CentOS系统. 1,首先需要检查一下服务器是否已经安装了VNC服务,检查服务器的是否 ...
- Qt之界面数据存储与获取(使用setUserData()和userData())
在GUI开发中,往往需要在界面中存储一些有用的数据,这些数据可以来配置文件.注册表.数据库.或者是server. 无论来自哪里,这些数据对于用户来说都是至关重要的,它们在交互过程中大部分都会被用到,例 ...
- Android:ScaleType设置图片
设置例子:ImageViewId.setScaleType(ScaleType.CENTER); ScaleType:设置图片显示方式 效果预览:
- Spring Framework 4.1.1
http://repo.spring.io/libs-release-local/org/springframework/spring/4.1.1.RELEASE/
- 【HDOJ】1667 The Rotation Game
1. 题目描述有个#字型的条带,可以从横线或竖线进行循环移动,求通过各种移动最终使中心的8个字符全等的长度最短并相同长度字典序最小的操作序列.2. 基本思路24个数据,8种移动方式,数据量很小了,所以 ...
- Eclipse下Preferences解析
General列表下: Keys设置快捷键 Appearance->Colors and Fonts->Text-Font设置字体和大小 Appearance->Startup an ...
- Nginx SPDY缓冲区溢出漏洞
漏洞版本: nginx 1.3.15 nginx 1.5.x 漏洞描述: CVE ID:CVE-2014-0133 Nginx是HTTP及反向代理服务器,同时也用作邮件代理服务器,由Igor Syso ...
- RMI、RPC、SOAP通信技术介绍及比对
1.RMI 使用java的程序员,对于RMI(RemoteMethod Invoke,远程方法调用)一定不陌生,在java中,为了在分布式应用开发时,能够方便调用远程对象,java提供了RMI的API ...
- c#里BindingFlags 筛选标志
下列 BindingFlags 筛选标志可用于定义包含在搜索中的成员: 为了获取返回值,必须指定 BindingFlags.Instance 或 BindingFlags.Static. 指定 Bin ...
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.1
Show that the inner product $$\bex \sef{x_1\wedge \cdots \wedge x_k,y_1\wedge \cdots\wedge y_k} \eex ...