从另一个页面的代码隐藏中获取ASP.Net页面的URL [英] Get URL of ASP.Net Page in code-behind from another page

查看:40
本文介绍了从另一个页面的代码隐藏中获取ASP.Net页面的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出从页面对象确定页面URL的方法.看来您只能获取当前上下文的路径.

I am trying to find away to determine a pages url from the page object. It seems you can only get the path of the current context.

推荐答案

页面可以有多个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

这篇关于从另一个页面的代码隐藏中获取ASP.Net页面的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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