How to - Friendly URLs

J

Jose

Hi All,

Could someone explain how the following functionality is implemented?
In modern "Web 2.0" sites user "profiles" (this is just one example)
are visible by a URL like "www.myapp.com/users/bob". Usually I have
implemented this by the following method -
"www.myapp.com/users/profile.aspx?user=bob". Would I need to use a http
handler and map it to "profile.aspx" if I can match the url "/users/"?

Any details would be appreciated. Any code samples would be nice too
:)

Thanks,

Jose
 
K

Kirk Allen Evans

What you are talking about is URL Rewriting. ASP.NET 2.0 provides simple
URL Rewriting in a limited fashion. That is, there are no wildcards
available or pattern matching options, each mapping corresponds to a single
URL. If you use querystrings, then you will end up with a config file that
looks like this:

<system.web>
<urlMappings enabled="true">
<add url="~/users/bob" mappedUrl="~/users/profile.aspx?user=bob"/>
<add url="~/users/keith"
mappedUrl="~/users/profile.aspx?user=keith"/>
<add url="~/users/kirk" mappedUrl="~/users/profile.aspx?user=kirk"/>
</urlMappings>
</system.web>


If this does not suit your needs, then consider something like
UrlRewriter.net.

http://urlrewriter.net/

--
Kirk Allen Evans
Developer Evangelist
Microsoft Corporation
blogs.msdn.com/kaevans

=== This post provided "AS-IS" with no warranties and confers no rights ===
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top