Lecture #6 - Asp.Net Core

Framework, Structure, Conventions

Web Resources
Asp.Net Core
Asp.Net is a platform for delivering web content. Asp.Net applications respond to requests by dynamically assembling web pages from control models and data, often from a database. Asp.Net was originally a Windows only platform. Asp.Net Core extends that to Linux and Mac platforms as well.
The Model-View-Controller (MVC) architecture has three major part types:
Views display information to the user and transmit user actions back to a controller. Controller instances are created for each request. They coordinate responses to the request by collecting data from the model and assembling it into a view for the response. Models manage data and often provide application logic to simplify controller operations.
Books Asp.Net Core Book - gitbooks
Tutorials Introduction to Asp.Net Core - MSDN, Razor Pages Tutorial - MSDN
Asp.Net Core - Dependency Injection - tutorialsteacher.com
References .Net Core Guide, Asp.Net Core Documentation - MSDN
Using .Net Core in Visual Studio Code
Razor syntax reference - MSDN, Create Razor Pages application
App startup, Static files in Asp.Net Core
File Uploads in Asp.Net Core
Understanding Asp.Net Core demystified, Asp.Net Core Demystified - Razor Pages
Asp.Net Core MVC Pipeline, View Layout
Configure Asp.Net Core services, Configure to use static files
Use Dependency Injection in Asp.Net Core, Dependency Injection Demystified, Dependency injection in Asp.Net Core
Dependency Injection Best Practices,
Building things Build a CRUD App with Web API and Angular
Asp.Net Core Arch, Asp.Net Core Hidden Gems - Scott Hanselman
HttpContext, HttpRequest Class, HttpResponse Class
REST Client, HttpClient Class
file upload and download, File Uploads in Asp.Net Core


We now turn our attention to Web Application Frameworks that assemble pages before delivery - We&aposll use the Asp.Net Core Framework. This lecture focuses on the structure of Asp.Net Core.
  1. Syllabus describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Projects: Final Project #1, Final Project #2, Final Project #3
    You will do one of these - the choice of which is yours to make - and present on the last day of classes.
    Additional Requirements
    You are expressly requested to refrain from using site editors like Wix, web.com, or other web designers. You may use any of the facilities of Visual Studio or any other text editor of your choice. This same rule applies to your lab submissions as well. For your Final Project demos you will be required to use only page links for navigation. You may host and demonstrate your labs in the built-in Visual Studio web server.
    All projects must use:
    • Asp.net core MVC - main site
    • Asp.net Web API - web service
    • Web API Client
    • SQL db storage
    • At least one static page that uses new features of HTML5, CSS3, and JavaScript6.
  3. Asp.Net Core Introduction to Asp.Net Core, pptx
    Asp.Net Core Pipeline
    Figure 1. Asp.Net Core Pipeline
    Dependency Injection References .Net Core Dependency Injection, Getting Started with Dependency Injection
    More References for DI Dependency Injection Tutorial Dependency Injection Best Practices, Use Dependency Injection in Asp.Net Core
    Illustrates one way a dependency injection container can create instances.
    C# Background Extension Methods Delegates, Delegate Structure Lambdas
  4. Interactive Demo - Asp.Net Core Build an empty project and populate it's pieces interactively. Web - nearly empty web application Pipeline - simple demo of how pipeline works Configure the basic Web application Message Service added to Web - uses Dependency Injection Service for static pages added to Web Mvc Web Application
    Build Process for Visual Studio File > New > Project
    Visual C# > Web > Asp.Net Core Web Application
    Provide name, Browser for Folder
    Left dropdown = Net Core, Right dropdown = Asp.Net 2.x
    Select Empty
    Build and Run to see "Hello World" From here we will add code to: - return web pages
    - add MVC structure
    Dissect project's parts
    • CreateWebHostBuilder
    • Startup
    • ConfigurationBuilder
    • ConfigureServices
    • AddSingleton<IMessageService, ConfigureMessageService>()
    • AddSingleton(provider => Configuration)
    • AddMvc()
    • Configure
    • app.UseFileServer
    • app.UseStaticFiles
    • app.UseDefaultFiles
    • app.UseMvcWidthDefalutRout()
    • app.Run(async (context) => { await context.Response.WriteAsync(msg.GetMessage()) }
  5. Lab #6