Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:17:51+00:00 2026-06-06T04:17:51+00:00

I have the following url http://localhost/user/MyUserName How do I get MyUserName from that url?

  • 0

I have the following url

http://localhost/user/MyUserName

How do I get “MyUserName” from that url? So I can use it at the server side to retrieve the information I want to present to the client side?

In Django it was very simply to archive that. But how do I do that in ASP.net MVC4?

EDIT

routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
      );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:17:52+00:00Added an answer on June 6, 2026 at 4:17 am

    I don’t know what did you name your route parameter

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}", 
         new {controller = "Home", action = "Index", id = UrlParameter.Optional}, 
         null,
         new[] {"Project.Web.Controllers"});
    

    But I suppose it’s Id anyway try this:

    var value = RouteData.Values["Id"];
    

    Update :

    In your case you should define a special route before ” on top of ” the default one :

    routes.MapRoute(
        "ForUser",
        "User/{id}", 
         new {controller = "User", action = "UserInfo", id = UrlParameter.Optional}, 
         null,
         new[] {"Project.Web.Controllers"});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that i have the following url in my site: http://localhost/test/example.php?a=1&b=2 How can i
I have the following URl: http://localhost:12981/BaseEvent/EventOverview/12?type=Film This is route: routes.MapRoute( Default, // Route name
I want to have possibility to access action by the following URL type: http://localhost/MyControllerName/MyActionName/Id1+Id2+Id3+Id4
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml
I have a URL which can be any of the following formats: http://example.com https://example.com
I have the following url structure: http://localhost/sitename/views/www/page.php I would like for page.php to show
I can enter via web http://localhost:8080/tfs/web with any user, from remote or local, but
I have the following line in my IsapiRewrite.ini file: RewriteRule ^/test-url.asp$ http://www.google.co.uk/ [R=301,L] But
So I have the following code: NSURL *baseURL = [NSURL URLWithString:@http://www.baseurltoanxmlpage.com]; NSURL *url =
I have the following code in my .Zshrc function google; { $VIEW http://www.google.com/search?q='url-encode ${(j:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.