Hello Friends Please Read this Post very carefully and you will find out that urlRewriting is as simple as get ball from chlids hand.
Please Follow the steps
First you need to decide that from .aspx which extenstion you want to rewrite your page .html,.htm,.asp or with wildcard charactres.
After that you will add one class file in app_code folder name with as you want but whatever name is given by you please add that name in wb.config module section how i will tell you in same post.
I m adding file name “urlrewrite.vb”
Imports Microsoft.VisualBasic
Public Class urlrewrite
Implements IHttpModule
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub
Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler context.BeginRequest, AddressOf OnBeginRequest
End Sub
Private Sub OnBeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim app As HttpApplication app = CType (sender, HttpApplication)
If app.Request.RawUrl.ToLower().Contains(”category.htm”)
Then
app.Context.RewritePath(”category.aspx”, “”, “msg=cat”)
ElseIf app.Request.RawUrl.ToLower().Contains(”product.html”)
Then
app.Context.RewritePath(”product.aspx”, “”, “msg=p”)
ElseIf
app.Request.RawUrl.ToLower().Contains(”test.aspx”)
Then
app.Context.RewritePath(”test.htm”, “”, “”)
End If
End Sub
End Class
After Complete this coding go to web.config add file name in module section
<system.web>
<httpModules>
<add name=”urlrewrite” type=”urlrewrite”/>
</httpModules>
</system.web>
After finish this all work enjoy url rewrting in .net application
Tags: .Net, Asp .Net Url ReWriting, Url Rewriting, Wild Character Url Re Writing
[...] How to Rewrite Url In Asp .Net [...]