如何获取当前页面的在C#中的网址 [英] How to get the URL of the current page in C#

查看:132
本文介绍了如何获取当前页面的在C#中的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我出在获得ASP.NET的当前工作页面的URL在C#?

Can anyone help out me in getting the URL of the current working page of ASP.NET in C#?

推荐答案

试试这个:

string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx

string host = HttpContext.Current.Request.Url.Host;
// localhost

这篇关于如何获取当前页面的在C#中的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆