When user enters an URL, for example: http://example-website.com/Example/HelloWorld, MVC application will use the routing rules to parse this url and extract the subpath, that will determine the controller, action and possible parameters. For the above url, the result will be /Example/HelloWorld, which by default routing rules results provides the name of the controller: Exmaple and the name of the action: HelloWorld.
public class ExampleController: Controller
{
public ActionResult HelloWorld()
{
ViewData["ExampleData"] = "Hello world!";
return View();
}
}
The above ActionResult method "HelloWorld" will render the view called HelloWorld, where we can then use the data from ViewData.