Last post Aug 25, 2010 05:45 AM by sheraz_aries
Aug 24, 2010 06:51 PM|sheraz_aries|LINK
I am trying to write a http module that redirect the url:
basically i got a lookup table that contain the Url Alias "breaking_news.aspx" and its associate ID. Any idea how can i accomplished it?
Aug 25, 2010 02:18 AM|itsmemuthu|LINK
u can opt for Url rewriting..
u have good examples here..
Hope it helps..
Aug 25, 2010 02:18 AM|hiren_andharia|LINK
This link will help you
If this link help you then please mark as answer
Aug 25, 2010 05:45 AM|sheraz_aries|LINK
Thanks for that ... I am using Scott's url rewritting
And got some rewriting rules setup in web.config file aswell. Now the task is to read the current url and check if there isn't any number on it (e.g http://www.mydomain.com/news/breaking_news.aspx ) then pass the url to the store proc that will query the
databse and return its respective id and then rewrite the url (like: http://www.mydomain.com/news/breaking_news.aspx?id=126574) .
Now i got the below class file with my url rewritter, but donno where and how should i place that functionality. Any ideas?
Public Class FormRewriterControlAdapter
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Public Class RewriteFormHtmlTextWriter
Sub New(ByVal writer As HtmlTextWriter)
Me.InnerWriter = writer.InnerWriter
Sub New(ByVal writer As System.IO.TextWriter)
MyBase.InnerWriter = writer
Public Overrides Sub WriteAttribute(ByVal name As String, ByVal value As String, ByVal fEncode As Boolean)
' If the attribute we are writing is the "action" attribute, and we are not on a sub-control,
' then replace the value to write with the raw URL of the request - which ensures that we'll
' preserve the PathInfo value on postback scenarios
If (name = "action") Then
Dim Context As HttpContext
Context = HttpContext.Current
If Context.Items("ActionAlreadyWritten") Is Nothing Then
' Because we are using the UrlRewriting.net HttpModule, we will use the
' Request.RawUrl property within ASP.NET to retrieve the origional URL
' before it was re-written. You'll want to change the line of code below
' if you use a different URL rewriting implementation.
value = Context.Request.RawUrl
' Indicate that we've already rewritten the <form>'s action attribute to prevent
' us from rewriting a sub-control under the <form> control
Context.Items("ActionAlreadyWritten") = True
MyBase.WriteAttribute(name, value, fEncode)