Last post Nov 18, 2010 01:25 PM by kmcnet
Nov 15, 2010 07:58 PM|kmcnet|LINK
Hello everyone and thanks for your help in advance. I am wanting to develop a URL Rewriting solution that handles postbacks and querystrings. I have found a couple of examples, but don't fully udnerstand the code and don't want to implement code I don't
understand. Obviously at the heart of this issue is intercepting the raw url before the rewrite occurs, however, I am not sure exactly how to go about this. Any help would be greatly appreciated.
Nov 15, 2010 11:57 PM|nareshvidhani|LINK
For url rewiting is mainly used for book marking and Search engine page ranking.
A very good artical on net is
please go through it
Hope this help
Nov 17, 2010 01:39 PM|kmcnet|LINK
Thanks for the useful article. However, it doesn't mention one point that I am trying to find a solution (that I understand). Let's say I have a multi-page article whose raw url would be:
I then rewrite the Url T
When I rewrite the URL, I am unable to retrieve the querystring "pg=1". Obviously, I need to set the original URL to an object, or the querystring parameters to an object and pass it to the new page, but I'm not exactly sure how to do so. Any insight would
be greatly appreciated.
Nov 18, 2010 12:00 AM|nareshvidhani|LINK
Can you explain me by the code where you are getting error.
Basically url rewriting doesn't need any extra code to retrive query string parameter.
Nov 18, 2010 01:25 PM|kmcnet|LINK
Here is the code I am using:
Public Class UrlRemapper
Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
AddHandler app.BeginRequest, AddressOf app_BeginRequest
Public Sub app_BeginRequest(ByVal s As Object, ByVal e As EventArgs)
' Get HTTP Context
Dim app As HttpApplication = CType(s, HttpApplication)
Dim context As HttpContext = app.Context
' Get current URL
Dim currentUrl As String = context.Request.AppRelativeCurrentExecutionFilePath
' Get URL Mappings
Dim urlMappings As XmlDocument = GetUrlMappings(context)
' Compare current URL against each URL from mappings file
Dim nodes As XmlNodeList = urlMappings.SelectNodes("//add")
For Each node As XmlNode In nodes
Dim url As String = node.Attributes("url").Value
Dim mappedUrl As String = node.Attributes("mappedUrl").Value
If Regex.Match(currentUrl, url, RegexOptions.IgnoreCase).Success Then
Private Function GetUrlMappings(ByVal context As HttpContext) As XmlDocument
Dim urlMappings As XmlDocument = CType(context.Cache("UrlMappings"), XmlDocument)
If urlMappings Is Nothing Then
urlMappings = New XmlDocument()
Dim path As String = context.Server.MapPath("~/UrlMappings.config")
Dim fileDepend As CacheDependency = New CacheDependency(path)
context.Cache.Insert("UrlMappings", urlMappings, fileDepend)
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
In the redirected page, I then try to access one of the querystring parameters such as Request.Querystring("PageNumber"), nothing is returned.
Thanks for the assistance.