Premium Only Content

Part 5 Views in an mvc application
In this video we will discuss views. Please watch Part 4 of MVC tutorial before proceeding. Let's change the Index() method in HomeController to return a list of country names. Since country names are strings, return List of strings. Get rid of id and name parameters.
Run the application and notice that the output is not as expected.
System.Collections.Generic.List`1[System.String]
To correct this problem, let's add a view to our project.
1. Right click on the Index() function
2. Click on "Add View"
3. Notice that, the view name in "Add View" dialog box matches the name of the controller action method
4. Select "Razor" as the view engine
5. Leave the rest of the defaults as is, and click "Add" button
We will discuss ViewBag & ViewData, and the differences between them in our next video session. For now, understand that, ViewBag & ViewData is a mechanism to pass data from the controller to the view.
Please Note: To pass data from controller to a view, It's always a good practice to use strongly typed view models instead of using ViewBag & ViewData. We will discuss view models in a later video session.
Please Note: We use "@" symbol to switch between html and c# code. We will discuss razor views and their syntax in a later video session.
-
5:55:33
MattMorseTV
7 hours ago $93.87 earned🔴Portland ANTIFA vs. ICE.🔴
146K295 -
3:13:00
Badlands Media
21 hours agoThe Narrative Ep. 40: Acceleratia.
51.6K13 -
LIVE
SpartakusLIVE
6 hours ago#1 Solo Spartan Sunday || TOXIC Comms, TACTICAL Wins, ENDLESS Content
909 watching -
49:45
Sarah Westall
5 hours agoComedians take Center Stage as World goes Nuts w/ Jimmy Dore
31.3K17 -
3:26:14
IsaiahLCarter
13 hours ago $5.88 earnedAntifa Gets WRECKED. || APOSTATE RADIO 030 (Guests: Joel W. Berry, Josie the Redheaded Libertarian)
43.2K1 -
LIVE
CassaiyanGaming
4 hours agoArena Breakout: Infinite Dawg
210 watching -
2:24:32
vivafrei
14 hours agoEp. 284: Ostrich Crisis Continues! Kirk Updates! Fed-Surrection Confirmed? Comey Indicted! AND MORE!
131K188 -
LIVE
Cewpins
4 hours agoSunday Sesh!🔥Rumble Giveaway Tonight!🍃420💨!MJ !giveaway
128 watching -
3:03:11
Conductor_Jackson
6 hours agoLet’s Play BioShock Infinite Burial at Sea Episode 2!
24.6K -
5:21:16
EricJohnPizzaArtist
6 days agoAwesome Sauce PIZZA ART LIVE Ep. #63: Charlie Sheen
54.7K4