Had got chance to share the concept on urlMmappings from ASP.NET 2.0

While watching (enjoyed) the success of our Sprit, I wrote a simple article on urlMmappings feature in ASP.NET 2.0. Take a look at that article at http://www.w3coder.com/alphatalks/v2urlmap.aspx

 

Hopefully it will be helpful to some one out there who is interested to know the new features in ASP.Net world!

Published Sunday, January 04, 2004 10:20 PM by SreedharK

Comments

# Thanks for your great article, I have a question

Sunday, May 16, 2004 1:40 AM by Yuejun Zhang
I know the way like:
<urlMappings enabled="true">
<add url="~/Home.aspx" mappedUrl="~/Default.aspx?tabid=0" />
</urlMappings>

but I wonder if there is a way to set-up a capturing expression in the url and refer to that capture in the mappedUrl with some expression.
so we can map "~/Home/*.aspx " to "~/Default.aspx?tabid=*" ;
e.g "~/Home/1.aspx " map to "~/Default.aspx?tabid=1" ;
"~/Home/2.aspx " map to "~/Default.aspx?tabid=2" ;
"~/Home/3.aspx " map to "~/Default.aspx?tabid=3" ;

.........
Thanks a lot

# re: Had got chance to share the concept on urlMmappings from ASP.NET 2.0

Sunday, May 16, 2004 7:30 AM by Sreedhar
Good quesiton, when I first got Alpha, I tried it, but it did not woked, The reason I guess it, ASP.NET services takes it as a string and parse it to see for that!!

I have tried to solve the same kind of business case by using Context.RewritePath technique.

As our luck, in ASP.NET(global.asax) we have App_BeginReq, by taking advantage of that we can solve it. Below could could helps you on your business case!

Sub Application_BeginRequest(ByVal Sender As Object, ByVal E As EventArgs)
Response.Write("CAme in")
'Response.End
'Aim: Convert a path of the form from x.aspx to yy.aspx?id=x

Dim context As HttpContext = HttpContext.Current

Dim pastpath As String = context.Request.Path.ToLower()
Dim DefPath As String = "/home/page"
Dim i As Int32 = pastpath.IndexOf(DefPath)
Dim DefPathlen As Int32 = DefPath.Length
'Response.Write(pastpath)
'Response.Write (i)
'Response.End
If (i <> -1) Then
Dim j As Int32 = pastpath.IndexOf(".aspx")
If (j <> -1) Then
Dim id As String = pastpath.Substring(i + DefPathlen, j - (i + DefPathlen))
Dim newpath As String = pastpath.Replace(DefPath + id + ".aspx",

"/Default.aspx?tabid=" + id)
context.RewritePath(newpath)
End If
End If

End Sub


Hope it helps you!!!

# Thanks a lot, it works great in my app

Monday, May 17, 2004 11:29 AM by Yuejun Zhang
Thanks a lot, it works great in my app.

Leave a Comment

(required) 
(required) 
(optional)
(required)