ASP.NET 客户端/浏览器 URL
我想知道如何从 ASP.NET 中的浏览器获取 URL。
我有一个用于全球化/本地化的页面,并且我正在从 www.spanishversion.com
重定向(通过服务器而不是代码)到 www.englishversion.com
,但是URL 被屏蔽后仍显示 www.spanishversion.com
。 我想获取浏览器的 URL 是什么,但是当我尝试以下操作时:
Request.Url.ToString()
Request.Url.OriginalUrl
Request.Path Request. RawUrl
Request.ServerVariables["SERVER_NAME"]
它始终返回为 www.englishversion.com
。 有没有办法可以从浏览器中显式读取 URL?
I'm wondering how I can get the URL from the browser in ASP.NET.
I have a page that I use with globalization/localization, and I am redirecting (via server not code) from www.spanishversion.com
to www.englishversion.com
, but the URL is masked to still say www.spanishversion.com
. I want to get what the browser's URL is but when I try things like:
Request.Url.ToString()
Request.Url.OriginalUrl
Request.Path Request.RawUrl
Request.ServerVariables["SERVER_NAME"]
It always comes back as www.englishversion.com
. Is there a way that I can explicitly read the URL from the browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用 Javascript 执行此操作,使用
location.href
。You can do this using Javascript, with
location.href
.尝试使用
Request.Url.Host
Try with
Request.Url.Host
尝试
从 MSDN
我用它来设置变量母版页。
try
from MSDN
I use it to set variables in a master page.
您可以尝试使用:
You can try to use:
我认为
Request.Url.AbsoluteUri
是你的朋友。I think
Request.Url.AbsoluteUri
is your friend.猜猜你对这种情况的理解是错误的。 您说地址栏被屏蔽以显示
www.spanishversion.com
,但它是否显示www.spanishversion.com
?Guess you got this situation wrong. You say the address bar is masked to show
www.spanishversion.com
, but is it showingwww.spanishversion.com
or not?