[英]Intelligencia.UrlRewriter
I'm using the Intelligencia UrlRewriter on a project. 我在一个项目上使用Intelligencia UrlRewriter。
It's working fine to rewrite urls typed into the browser. 重写在浏览器中键入的URL可以正常工作。
For example, if I enter 例如,如果我输入
http://localhost/People
This is being correctly rewritten as: 这被正确地重写为:
http://localhost/People.aspx
Now, the problem is, when I am in the code behind I need to access the Friendly URL, but Request.ServerVariables seems to only have the unfriendly URL available. 现在的问题是,当我在后面的代码中时,我需要访问Friendly URL,但是Request.ServerVariables似乎只有不友好的URL可用。
Does anyone know if there's anyway I can access this original, friendly Url in code? 有人知道我是否仍然可以通过代码访问此原始友好的网址? Or am I too late?
还是我来不及?
Got it guys. 知道了
@Nick Allen and Pure.Krome: Thanks for the help!! @尼克艾伦和Pure.Krome:谢谢您的帮助!
I found the piece of data in: 我在以下位置找到了数据:
HttpContext.Current.Request.RawUrl
If it exists in ServerVariables, I couldn't see it, but in conclusion, the data is there so I won't have to cry myself to sleep :) 如果它存在于ServerVariables中,则看不到它,但是总而言之,数据在那里,所以我不必哭泣自己就可以入睡了:)
Okay. 好的。 Thanks again!!
再次感谢!!
Request.PathInfo
Request.QueryString
Which one you use depends on if you rewrite to default.aspx?myvar
or default.aspx/myvar
使用哪一种取决于您是否重写为
default.aspx?myvar
或default.aspx/myvar
I'm using it and have been for .. er .. 2 years now i think. 我正在使用它,并且已经使用了.. er .. 2年了。 (Thank gawd IIS7 and MVC are here ! )
(感谢gawd IIS7和MVC在这里!)
anyways, can u check the IIS Server Variables for all of these and tell us what you get... 无论如何,您能检查所有这些的IIS服务器变量并告诉我们您得到了什么...
eg (this is a snippet of the PATH_INFO for a page i have set up which dumps ALL the request variables) :- 例如(这是我设置的转储所有请求变量的页面的PATH_INFO的片段):-
PATH_INFO: [/admin/Miscellaneous.aspx]
PATH_INFO:[/ admin / Miscellaneous.aspx]
and to get it .. 并得到它..
Request.ServerVariables["PATH_INFO"]
Keep us posted. 保持联系。
The Intelligencia rewrite rules are stored in the web.config, which is parsable. Intelligencia重写规则存储在可解析的web.config中。 So you could traverse the rules in the web.config to find a match and use the matched value from there
因此,您可以遍历web.config中的规则以找到匹配项,然后从那里使用匹配的值
Obviously this would not work for pattern matching, just explicit rules such as the one in your example 显然,这不适用于模式匹配,仅适用于显式规则(例如您的示例中的规则)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.