Click here to Skip to main content
15,126,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create public profile for all members who sign up like in facebook: facebook/username redirects to user's profile how can i get this? profile page may look like this www.example.com/users.aspx?user=john i want to get this by typing www.example.com/john.. i am using asp.net 4.0, visual studio 2010, sqlserver server 2005 (linq)
thanx in advance..
Posted
Comments
Sharma Richa 28-Mar-12 2:29am
   
You can use the concept of url rewritting.
aroonthapa 28-Mar-12 2:43am
   
thanx richa
i followed this link http://asp-dotnet-notes.blogspot.com/2012/03/vanity-url-using-url-rewriting-in.html but could nt get exactly what i needed. Its works fine with www.example.com/users/john but what i need is www.example.com/john.
thursunamy 28-Mar-12 6:34am
   
Did you look at Url Routing. It is easier than Url Rewrite
aroonthapa 28-Mar-12 6:45am
   
thanx thursunamy but i tried my best.

1 solution

Hi,

Try this


C#
using System;
using System.Web.Routing;

namespace UrlRewriting
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        public static void RegisterRoutes(RouteCollection routeCollection)
        {
            routeCollection.MapPageRoute("RouteForCustomer", "{Id}", "~/User.aspx");
        }

    }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900