ASP.Net URL Routing RRS feed

  • Question

  • Dears

    i have a new websit but till now it is working localhost and i want to pass the name of the user to be www.domain.com/username ,,, i will take the name of the user from the database by using sql query so i want to make a profile to the user that all can contact with him by write his username after the domain ( Like facebook ) ,, how can i doing this ,,, please any developer give me the c# code 

    best regards

    Friday, August 16, 2013 1:44 AM


  • Hi Beljik,

    you will need couple of things on your project, as you definitely said you need routes, as an example this is how you can define your route that allows sitename.com/UserName

    context.MapRoute("nameofRoute", "{UserName}", new { controller = "controller_name", action = "Action_Name" }, new string[] { typeof(fullyqualifiedtypename).Namespace });

    beside this route, per example i gave you (from an mvc application i am writing) you will need a controller and the action that will handle the request.

    hope this helps


    Please mark as answered if it helped

    Please mark as answered if it helped Vishal Narayan Saxena http://twitter.com/vishalishere http://www.ogleogle.com/vishal/

    Friday, August 16, 2013 5:17 AM