Bootstrap FreeKB - MVC - Retrieve values from a URL
MVC - Retrieve values from a URL

Updated:   |  MVC articles

In this example, let's say we want to display something unique based on the id value in the URL. For example, let's say we have these two URLs:

  • www.example.com/MVC/Home/Index?username=Jeremy
  • www.example.com/MVC/Home/Index?username=Natalie

When Jeremy is requested, we want to display "Welcome Jeremy". When Natalie is requested, we want to display " Welcome Natalie" Add the following to Index string of the HomeController class:

public string Index(string username)
{
    return "Welcome " + username;
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 24f58c in the box below so that we can be sure you are a human.