Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Learn how the "controller" in MVC acts as the intermediary between users, data, and presentation.
Although C is the last letter in MVC,
0:00
I'm gonna start with it first
because it runs the show.
0:02
C stands for controller, and it handles
a the communication between a user and
0:06
the various parts of an application.
0:10
For example a, user wouldn't talk
directly to the database on IMBb.com.
0:13
Instead, they would
visit a page like this.
0:19
The URL is known as a route, and
0:22
represents a request to see information
on the classic movie Toy Story.
0:24
The URL is routed to the controller.
0:29
Remember, the controller handles all
of the communication in the app.
0:32
The controller then knows
that it needs some data.
0:36
So it requests information
about the movie.
0:39
On a complex web application, you may
need to create multiple controllers,
0:43
each to handle a different
type of request.
0:47
For example, one controller to handle
logging in and out of the website.
0:50
Another controller to handle requests for
movie data.
0:55
Or a handler to process requests from
users who want to download movie files.
0:58
There are more steps to the process,
which I'll discuss in the next videos.
1:04
But at this point,
keep in mind that controllers act
1:08
as an interface between a user and
the behind the scenes magic of an app
1:11
You need to sign up for Treehouse in order to download course files.
Sign up