Intelligencia.UrlRewriter
我正在一个项目中使用 Intelligencia UrlRewriter。
重写浏览器中输入的网址工作正常。
例如,如果我输入
http://localhost/People
This is is being Correctly rewriting 为:
http://localhost/People.aspx
现在,问题是,当我在后面的代码中时,我需要访问友好的 URL,但 Request.ServerVariables 似乎只有不友好的 URL 可用。
有谁知道我是否可以通过代码访问这个原始的、友好的 URL? 还是我太晚了?
I'm using the Intelligencia UrlRewriter on a project.
It's working fine to rewrite urls typed into the browser.
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.
Does anyone know if there's anyway I can access this original, friendly Url in code? Or am I too late?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
明白了,伙计们。
@Nick Allen 和 Pure.Krome:感谢您的帮助!
我在以下位置找到了这条数据:
如果它存在于 ServerVariables 中,我看不到它,但总而言之,数据就在那里,所以我不必哭着入睡:)
好吧。 再次感谢!!
Got it guys.
@Nick Allen and Pure.Krome: Thanks for the help!!
I found the piece of data in:
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 :)
Okay. Thanks again!!
使用哪一个取决于您重写为
default.aspx?myvar
还是default.aspx/myvar
Which one you use depends on if you rewrite to
default.aspx?myvar
ordefault.aspx/myvar
我正在使用它并且已经使用了..呃.. 2年了,我想。 (感谢 gawd IIS7 和 MVC 在这里!)
无论如何,你可以检查 IIS 服务器所有这些的变量并告诉我们您得到了什么...
例如(这是我设置的转储所有请求变量的页面的 PATH_INFO 的片段):-
并获取它..
随时通知我们。
I'm using it and have been for .. er .. 2 years now i think. (Thank gawd IIS7 and MVC are here ! )
anyways, can u check the IIS Server Variables for all of these and tell us what you get...
eg (this is a snippet of the PATH_INFO for a page i have set up which dumps ALL the request variables) :-
and to get it ..
Keep us posted.
Intelligencia 重写规则存储在可解析的 web.config 中。 因此,您可以遍历 web.config 中的规则来查找匹配项并使用其中的匹配值
显然这不适用于模式匹配,只需明确的规则,例如您示例中的规则
The Intelligencia rewrite rules are stored in the web.config, which is parsable. So you could traverse the rules in the web.config to find a match and use the matched value from there
Obviously this would not work for pattern matching, just explicit rules such as the one in your example