Intelligencia.UrlRewriter
-
08-07-2019 - |
Question
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?
Solution
Got it guys.
@Nick Allen and Pure.Krome: Thanks for the help!!
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 :)
Okay. Thanks again!!
OTHER TIPS
Request.PathInfo
Request.QueryString
Which one you use depends on if you rewrite to default.aspx?myvar
or default.aspx/myvar
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...
- PATH_INFO
- URL
- SCRIPT_NAME
eg (this is a snippet of the PATH_INFO for a page i have set up which dumps ALL the request variables) :-
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. 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