Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在asp.net 3.5中读取重写的url_Asp.net_Url Rewriting_Iirf - Fatal编程技术网

如何在asp.net 3.5中读取重写的url

如何在asp.net 3.5中读取重写的url,asp.net,url-rewriting,iirf,Asp.net,Url Rewriting,Iirf,如何读取重写的url。如果我在重写的url中不使用.aspx,则“Request.RawUrl”不起作用。它正在返回原始URL 请建议您是否有任何解决方案。我正在使用Ionics Isapi重写过滤器(IIRF) 例如,如果我已重写: http://<mywebsite>/users.aspx?id=12&name=amitava http:///users.aspx?id=12&name=amitava 到 http:///profile/12/amitava 现在在

如何读取重写的url。如果我在重写的url中不使用.aspx,则“Request.RawUrl”不起作用。它正在返回原始URL

请建议您是否有任何解决方案。我正在使用Ionics Isapi重写过滤器(IIRF)

例如,如果我已重写:

http://<mywebsite>/users.aspx?id=12&name=amitava
http:///users.aspx?id=12&name=amitava

http:///profile/12/amitava
现在在同一个页面中,在某个时刻,我想要得到这个重写器url,以便在登录链接中指向返回url。现在,登录链接应该是:

http://<mywebsite>/login.aspx?ReturnUrl=/profile/12/amitava
http:///login.aspx?ReturnUrl=/profile/12/amitava

http:///login.aspx?ReturnUrl=http:///profile/12/amitava

实现这一目标的正确方法是什么?谢谢。

您正在使用IIS重写模块吗?
如果您是
HttpContext.Current.Request.RawUrl
则应提供重写后的URL,而
HttpContext.Current.Request.URL.OriginalString
则应提供非重写URL。

对于IIRF,这称为解混,可通过使用修饰符
U
实现

从:

U=在服务器中存储原始url 变量HTTP_X_REWRITE_URL

只需将修饰符
U
添加到要保留原始url的
重写规则
。例如:

RewriteRule ^yourexpression$ yourrewrittenurl [I,U,L] 
然后,在页面的代码中,您可以访问原始url,如下所示:

Request.ServerVariables("HTTP_X_REWRITE_URL")

另请参见我的

我正在使用IIRF重写moduleTried Request.RawUrl,但它正在返回未重写的URL好的,我得到了答案。它在这里工作
RewriteRule ^yourexpression$ yourrewrittenurl [I,U,L] 
Request.ServerVariables("HTTP_X_REWRITE_URL")