且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从另一个页面的代码隐藏中获取ASP.Net页面的URL

更新时间:2023-01-08 12:54:37

页面可以有多个URL.例如,我有一台正在家里运行的服务器,该站点的URL取决于我从何处进行检查.当我在家时,我只使用内部服务器名称,以便流量永远不会离开我的家庭网络.当我在其他地方时,必须使用基于dyndns.org的url.我还可以将几个不同的站点配置为全部指向同一个地方.关键是该信息与您页面的类类型甚至特定实例无关.

A page can have several urls. For example, I have a server running at home and the site's url is different depending on where I check it from. When I'm at home I just use the internal server name so that the traffic never leaves my home network. When I'm elsewhere I have to use the dyndns.org -based url. I could also configure several different sites to all point to the same place. The point is that this information is not tied to your page's class type, or even a specific instance.

因此,只能根据每个请求确定页面的URL,并且可以肯定的是,通过查看

Therefore, the URL of a page can only be determined on a per-request basis, and sure enough you can get it by looking at Request.Url