ASP.NET中几种获取URL的方法


//获取完整url (协议名+域名+站点名+文件名+参数)  

string fullUrl = Request.Url.ToString();

//获取客户端请求的URL信息(不包括主机和端口)  

string rawUrl = Request.RawUrl;

//获取站点名+页面名  

string absolutePath = Request.Url.AbsolutePath;

//获取主机部分  

string urlHost = Request.Url.Host;

//获取参数部分  

string urlQuery = Request.Url.Query;

//获取服务器上ASP.NET应用程序的虚拟路径  

string ApplicationPath = Request.ApplicationPath;

//获取当前请求的虚拟路径  

string CurrentExecutionFilePath = Request.CurrentExecutionFilePath;

//获取当前请求的虚拟路径  

string Path = Request.Path;

//获取具有URL扩展名的资源的附加路径信息

string PathInfo = Request.PathInfo;

//获取与请求的URL相对应的物理文件系统路径

string PhysicalPath = Request.PhysicalPath;

//获取文件名的本地操作系统表示形式  

string LocalPath = Request.Url.LocalPath;

//获取绝对URL

string AbsoluteUri = Request.Url.AbsoluteUri;

相关阅读 >>

c# 返回对象obj的string值,obj为null时返回空值

c#中引用类型之特例string的详细介绍

char数组如何转string

.net框架-string是value还是reference type的详解

c#中string类型与json之间相互转换的实现方法

c#中enum与string的相互转换的示例

常用c#关键字详解教程

简述c#中builder和buffer类的用法详解

mvc中获得controller、URL及action的asp.net方法详解

[asp.net mvc 小牛之路]07 - URL routing

更多相关阅读请进入《URL》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...