article

Introduction to asp.net5

Lesson 3 - introducing MVC

[WHAT]

  1. ] VIDEO SUMMARY - summary notes on the video, this lesson ...   - introducing MVC

[WHY]

[WHERE]

  1. ] WATCH THE FULL VIDEO
    1. ] Introduction to asp.net5 - Lesson 3 - MVC

[WHEN]

  1. ] 2015-08-12 - created 
  2. ] 2015-09-15 - published

[EXAMPLE]

  1. [00:00] introduction
    1. ] Scott Hanselman - 
    2. ] Glen Condron -  
    3. ] previous lesson - we talked previous about the relationships between VS, the browser, app and the web server, we created an empty app, talked a little bit about "middleware" 
    4. ] current lesson (this) - we are going to talk about model view controller the "MVC", the design pattern, it is used by asp.net and many other frameworks (ruby, python, windows forms ), will build an app using the "default template", will use docs.asp.net tutorial
  2. [01:30] my "learning node" experience 
    1. ] grabbed yeoman generator, generated a bunch of files to create an app
    2. ] but - i didnt really know what they all did
    3. ] realized VS (does the same) but because "i know it" i understand what the different stuff does, somone new may not ...
    4. ] another "noobie" problem is - how deep do you need to go in the "stack" 
    5. ] the stack -  everything thats involved in the operation of your app from the top to the bottom, 
    6. ] we(msft) try to take care of(abstract) much of the details, now with everything being open source, you can go as deep as you want, if you want to 
  3. [03:45] file new project - mvamvc
    1. ] choose the "web appication" template which is the "default" choice for new application
    2. ] the "change authentication" option enables you to change the default auth, by default the "individual user accounts" option is enabled for new web applications
    3. ] options = ] no authentication ] individual user accounts ] work and school accounts ] windows authentication 
    4. ] choosing x] no authentication for example, simpler to understand
  4. [06:00] reviewing the content the new project - default web application template
    1. ] references - contains our nuget packages, all files required for the template are on the local machine, 
    2. ] more packages then the "empty" app, includes packages for "mvc", "diagnostics", "static files", "web listener", "logging", "configuration", ...
    3. ] lego peices, modular, seperation of concerns
    4. ] you dont need to really worry to much about whats in here
  5. [08:30] reviwing "startup.cs" - its different
    1. ] theres is lots more going on in this one then in the "empty" one
    2. ] we now have Configure, (as before) but also ConfigureServices, a Constructor method, ...
    3. ] Startup() - constructor - the first method to execute, 
    4. ] ConfigureServices() - put/add all of the things that your app might need to use later on, the classes that you will need to run, ex MVC, you are not using it, just telling that we may use it
      1. ] add MVC - services.addMVC();
    5. ] Configure()
      1. ] use MVC - app.UseMVC( args route=>.. );
  6. [13:30] folders for "controllers" and "views"
    1. ] home.cs file in controller and home.cshtml in views 
    2. ] launches app to show, home page, also has "about" and "contact" pages
    3. ] trying to access anything else, returns an "error" page
  7. [16:15] home.cs the home controller
    1. ] VS TIP - shift + alt + enter - displays code window full screen,
    2. ] VS TIP - ctrl + scroll - to zoom in
    3. ] breakpoint - stop code from running when it gets to that point
    4. ] home controller delegates to index view
  8. [24:00] MVC explained
    1. ] the classic MVC slide - 
    2. ] new MVC slide - request -> controller ( looks at request, makes or gets Model, does stuff )
    3. ] request -> controller \/
    4. ]                  view - transforms the model into HTML
    5. ] response <- 
    6. ] the "model" - holds the app data, is the means of communication between "controllers" and "views", holds no app logic
  9. [27:00] adding a new "method" named "foo" to the "home controller"
    1. ] copy and pasted the Index method, renamed it as the "Foo" method, tried to access the Foo page, results in an error
    2. ] Error says "Foo" view was not found, we looked here ...
    3. ] \views - 
    4. ] \shared - 
    5. *] new error page format with Stack and Query, Cookies, Headers and Environment
    6. ] we learn that we need a Foo "view" page that corresponds to  
    7. ] we learn where the server will look for said view page
  10. [29:00] adding a new "view" named "foo"
    1. ] right click on the views folder , choose "MVC view" from the options, 
    2. ] add "your content" to the "view"
    3. ] access by URL - yoursite.com/foo
    4. ] hey this page also contains top nav bar ( menu ) that we didnt add to our view, where did that come from?
    5. ] check out /Shared folder for the "_Layout.cshtml" file 
    6. ] _Layouts is like a template where you can define all of "common elements" for a "page", things like menus, headers, footers, ....
  11. [30:00] a peak at "taghelpers"
    1. ] we add a menu item to the existing menu to access our new Foo page, NOTE that we are NOT using standard html but the attributes of < a asp-controller=Home asp-action=Foo> WHERE these a attributes specify the Controller and the Method(Action) that the link will point to, the attributes will generate that appropriate HTML source code
  12. [31:00] what if ..
    1. ] change the Foo method, to return a "string", instead of a "view", this works too, the browser gets plain text
    2. ] well talk more about this when we cover web api's - where we return different things like json, xml, javascript, ...
  13. [32:00] VS tips and tricks 
    1. ] DYN - in the VS IDE a "red squiggly" line means there is an error in your code statement, use the "mouseover" to get a detailed description of that error
    2. ] TIP - Ctrl+F5 - starts your application without debugging - this is faster then the usual F5, BUT if you have breakpoints set, it will bypass them
    3. ] TIP - quicklaunch
    4. ] TIP - Ctrl + , - 
  14. [33:00] "ViewData" 
    1. ] passing data into your view
    2. ] data could be anything(object, db.query, ...), obtained from anywhere() )
  15. [35:00] about "browserlink" 
    1. ] very cool "connection" between the web page in the browser and the source code in the VS IDE, 
    2. ] dependancy must be specified in project json file
    3. ] wont be available in production environment
  16. [41:00] review 
    1. ] model holds the data, we used "ViewData" as a "cheap" model
    2. ] controllers and views communication
    3. ] view decides ....
    4. ] in more advanced cases, you can have a "viewmodel aka a model that is specific to the view
    5. ] your current view may only need a specific part of you
    6. ] next = a more sophisticated model and a bootstrap
    7. ] explanation F5 vs Ctrl+F5 

[HOW-TO]

  1. ] # 5050 - my project - guide to asp.net - MVC
    1. ] # # -

[REFERENCE]

  1. # 4804 - overview series 

 

quiz

1. By default, which type of authentication does a new Microsoft ASP.NET 5 application use?

2. Which three of the following are part of the lifecycle of Startup.cs? Choose three.

3.  True or false: You can use IIS Express to serve webpages to other computers on the network.

4. In a default Microsoft ASP.NET 5 MVC web application, which file should you edit to add an item to the navigation bar of every page?

5. What enables you to use the F12 Developer Tools to navigate code in Microsoft Visual Studio?

results = 5/5 total = 107 , rank.local = 1426, rank.global = 95,537 total=3,555,000. % completed = 30

 

 

 

 

 

 

 

 

 

Details Photos Edit more

Details

ID: 4807

NAME: introduction-asp.net5-lesson-3

DESCRIPTION: [46:15] VIDEO-SUMMARY Introduction to asp.net5 - Lesson 3 - introducing MVC - by Scott Hanselman and Glen Condron

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and