脚本宝典收集整理的这篇文章主要介绍了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;
完整代码演示
以上是脚本宝典为你收集整理的ASP.NET获取URL方法汇总全部内容,希望文章能够帮你解决ASP.NET获取URL方法汇总所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。