I have a dynamic web site that I am trying to make "search engine friendly" by dynamically creating URL's without parameters.
IE http://www.MySIte.com/MySubFolder/My...x?Entry_ID=256 is rewritten to http://www.MySIte.com/Entry256.aspx
In the Application_BeginRequest method of the global.asax, I search for the first x characters of the page name and use Context.RewritePath to the actual page.
IE
Dim strPath As String = Request.FilePath
Dim intStart As Integer = strPath.LastIndexOf("/") + 1
Dim intEnd As Integer = strPath.LastIndexOf(".aspx")
Dim intLength As Integer = intEnd - intStart
Dim strNewPath As String
Dim strPageName As String = strPath.Substring(intStart, intLength)
If strPageName.Substring(0, 4) = "Entr" Then
strNewPath = "~/MySubFolder/MyPage.aspx?Entry_ID=" & strPageName.Substring(6, intLength - 6)
Context.RewritePath(strNewPath)
URL's now do not have parameters and are now search engine and user fiendly!
This worked great until I found that server.transfer doesn't invoke this method. No problem - switched to response.redirect.
Only remaining problem are form postbacks. When a user friendly URL form has a postback, the old "ugly" URL with parameters is now displayed. Any work around for this?
Thanks,
Jeff




Reply With Quote