ASP Module 2
Getting Started with MVC
Getting Started with MVC
  • Overview
    • Introduction to MVC
  • Understanding MVC
    • Creating an MVC app
    • Add a controller
      • Understand HTTP endpoint
      • Understand basic routing
    • Add a view
      • Understanding shared layouts
      • Setting view title
      • Passing data to view
  • Exercise
    • Add two numbers
      • Using Model
  • Display Movies
    • Add a model
      • Scaffold the index view
      • Scaffold the movies controller
      • Add temp movie data
      • Pass data to index view
    • Implement actions
      • The first create action
      • The second create action
      • The details action method
      • Edit & Delete actions
      • Asynchronous actions
    • Repo link
Powered by GitBook
On this page
  1. Understanding MVC
  2. Add a controller

Understand HTTP endpoint

PreviousAdd a controllerNextUnderstand basic routing

Last updated 2 years ago

Understand HTTP endpoint

An HTTP endpoint:

  • Is a targetable URL in the web application, such as https://localhost:5001/HelloWorld.

  • It Combines:

    • The protocol used: HTTPS.

    • The network location of the web server, including the TCP port: localhost:5001.

    • The target URI: HelloWorld.

The first comment states this is an method that's invoked by appending /HelloWorld/ to the base URL.

The second comment specifies an method that's invoked by appending /HelloWorld/Welcome/ to the URL. Later on we will look into HTTP POST methods, which update data.

Run the app if required or save to hot reload

Append "HelloWorld" to the path in the address bar. The Index method returns a string.

Browser window showing an app response of This is my default action

MVC invokes controller classes, and the action methods within them, depending on the incoming URL.

/[Controller]/[ActionName]/[Parameters]

The default used by MVC, uses a format like this to determine what code to invoke:

URL routing logic
HTTP GET
HTTP GET