如何获取原始网址 [英] how to get original url

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

问题描述

我正在使用URL重写器:

i am using url rewriter:

<rewriter>
    <rewrite url="~/articles/(.+)-(.+).aspx" to="../articles/details.aspx?test-for-stream-5-2778"/>
  </rewriter>



每次我调用Request.Url时,它都会给出如下输出:
../articles/details.aspx?test-for-stream-5-2778

但实际网址不同.
所以任何人都可以帮助我如何获取原始网址.我认为我在url重写中出了点问题.
请检查此代码,并帮助我获取网址.
在此先感谢



every time when i call the Request.Url then it give the output like this :
../articles/details.aspx?test-for-stream-5-2778

but actual url is different.
so can any one help me how to get the original url. I think i am going something wrong in url rewrite.
please check this code and help me to get the url.
Thanks in advance

推荐答案

使用以下命令获取原始网址:
-HTTP_X_ORIGINAL_URL –此服务器变量包含解​​码格式的原始URL;
-UNENCODED_URL –此服务器变量包含与Web客户端完全相同的原始URL,并保留了所有原始编码.
请参阅本节:保留原始URL [ ^ ].


不仅如此,在URL重写中,对于请求,您还可以使用Request.RawUrl属性来检索原始URL.
参考:提示/技巧:网址重写使用ASP.NET [ ^ ]
Use the following to get the original url:
- HTTP_X_ORIGINAL_URL – this server variable contains the original URL in decoded format;
- UNENCODED_URL – this server variable contains the original URL exactly as it was requested by a Web client, with all original encoding preserved.
Refer this section: Preserving Original URL[^].


Not just it, in URL rewriting, for Requests, you can use Request.RawUrl property to retrieve the original url.
Refer: Tip/Trick: Url Rewriting with ASP.NET [^]


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

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