KEMBAR78
Introduction-to-ASPNET-Core ASP.NET.pptx
Introduction to ASP.NET
Core
Welcome to this introductory lecture on ASP.NET Core! This presentation
aims to provide you with a foundational understanding of ASP.NET Core,
guiding you through its architecture, project setup, and basic application
development. We'll start with a brief recap of ASP.NET, move into the core
concepts, and then dive into creating your first ASP.NET Core web
application. By the end of this lecture, you'll be equipped to build and run a
simple web app, setting the stage for more complex projects.
by Eng-Abdulahi Mohamed Adan
Recap: What is ASP.NET?
Web Development Framework
ASP.NET is a web development
framework created by Microsoft for
building dynamic web applications. It
provides tools and libraries for creating
websites, web applications, and web
services.
Supports MVC and Web API
ASP.NET supports both Model-View-
Controller (MVC) and Web API
architectures. MVC helps in separating
concerns, while Web API is used for
building RESTful services.
Development Setup
Ensure Visual Studio and the .NET SDK
are installed and working correctly.
Verify you can create and run a simple
console application to confirm your
environment is set up.
Introduction to ASP.NET Core
1 Cross-Platform Framework
ASP.NET Core is a cross-platform, high-performance framework
designed for building modern, cloud-based web applications. It
runs on Windows, Linux, and macOS.
2 Open Source
It is open-source, allowing developers to contribute to the
framework's development and customize it to suit their needs.
This promotes community-driven improvements and
transparency.
3 Supports MVC and Razor Pages
ASP.NET Core supports both MVC and Razor Pages development
models. Razor Pages simplify the development process for page-
focused scenarios.
4 Dependency Injection and Middleware
It features built-in dependency injection for managing
dependencies and middleware for handling HTTP requests,
making it highly extensible and testable.
ASP.NET Core Architecture
Request-Response
Pipeline
The request-response pipeline is
the backbone of ASP.NET Core,
handling incoming HTTP
requests and generating
appropriate responses. It is
configured using middleware
components.
Middleware
Middleware components process
requests and responses, adding
functionality like authentication,
logging, and routing. They form
a chain that each request passes
through.
Controllers and Views
Controllers handle application
logic, interacting with models
and selecting views to render UI.
Views are Razor pages that
define the structure and content
of web pages.
Routing
Routing defines how URLs are
mapped to controllers and
actions, enabling clean and
organized navigation throughout
the application. Custom routes
can be configured to meet
specific needs.
Creating a New ASP.NET Core Project
Open Visual Studio
Launch Visual Studio and click on "Create a new project" to start building your first ASP.NET Core
application.
Select ASP.NET Core Web App (MVC)
Choose the "ASP.NET Core Web App (Model-View-Controller)" template to create a project that follows
the MVC architectural pattern.
Configure Project Settings
Enter a project name, choose a location, and configure any additional settings before clicking
"Create" to set up your project.
Project Setup
Wait for Visual Studio to complete the project setup, which includes generating the necessary files
and dependencies for your ASP.NET Core application.
Understanding Project Structure
Controllers
The "Controllers" folder contains the logic for handling HTTP requests. Each controller is a
class that manages interactions and data flow for specific features.
Views
The "Views" folder stores Razor pages (.cshtml files) responsible for UI rendering. Views use
HTML and C# code to display dynamic content.
Models
The "Models" folder represents data structures used in the application. Models define the
properties and behavior of the data being managed.
wwwroot
The "wwwroot" folder stores static files like CSS, JavaScript, and images. These files are directly
served to the client browser.
Hands-on Activity: Modifying the Homepage
1
Open Index.cshtml
Navigate to Views > Home > Index.cshtml to access the homepage view file.
2
Modify the Heading
Change the <h1> heading to "Welcome to My First ASP.NET Core App!" to
customize the page title.
3
Save and Run
Save the changes and run the project to see the updated
homepage in your web browser.
Adding a New Controller and Action Method
Add Controller
1
Create Method
2
Save and Run
3
Go to the Controllers folder, right-click, and select Add > Controller. Choose MVC Controller - Empty and name it HelloController.cs. Add an action method named Greet that returns "Hello, ASP.NET Core!". Save and run the
application, then navigate to /Hello/Greet to view the result.
using Microsoft.AspNetCore.Mvc;
namespace MyApp.Controllers
{
public class HelloController : Controller
{
public IActionResult Greet()
{
return Content("Hello, ASP.NET Core!");
}
}
}
Q&A and Homework
Q&A Session
• Project structure
• Controller-view interaction
• Purpose of routing
Take the time to ask questions about the project structure,
how controllers and views interact, and the purpose of
routing. Your questions will make sure everyone is ready for
the homework assignment.
Homework Assignment
1. Create UserController
2. Add Profile action
3. Modify Index.cshtml
The homework assignment is to create a new controller called
UserController, add an action method Profile that returns
"User Profile Page", and modify Index.cshtml to include a link
to /User/Profile.

Introduction-to-ASPNET-Core ASP.NET.pptx

  • 1.
    Introduction to ASP.NET Core Welcometo this introductory lecture on ASP.NET Core! This presentation aims to provide you with a foundational understanding of ASP.NET Core, guiding you through its architecture, project setup, and basic application development. We'll start with a brief recap of ASP.NET, move into the core concepts, and then dive into creating your first ASP.NET Core web application. By the end of this lecture, you'll be equipped to build and run a simple web app, setting the stage for more complex projects. by Eng-Abdulahi Mohamed Adan
  • 2.
    Recap: What isASP.NET? Web Development Framework ASP.NET is a web development framework created by Microsoft for building dynamic web applications. It provides tools and libraries for creating websites, web applications, and web services. Supports MVC and Web API ASP.NET supports both Model-View- Controller (MVC) and Web API architectures. MVC helps in separating concerns, while Web API is used for building RESTful services. Development Setup Ensure Visual Studio and the .NET SDK are installed and working correctly. Verify you can create and run a simple console application to confirm your environment is set up.
  • 3.
    Introduction to ASP.NETCore 1 Cross-Platform Framework ASP.NET Core is a cross-platform, high-performance framework designed for building modern, cloud-based web applications. It runs on Windows, Linux, and macOS. 2 Open Source It is open-source, allowing developers to contribute to the framework's development and customize it to suit their needs. This promotes community-driven improvements and transparency. 3 Supports MVC and Razor Pages ASP.NET Core supports both MVC and Razor Pages development models. Razor Pages simplify the development process for page- focused scenarios. 4 Dependency Injection and Middleware It features built-in dependency injection for managing dependencies and middleware for handling HTTP requests, making it highly extensible and testable.
  • 4.
    ASP.NET Core Architecture Request-Response Pipeline Therequest-response pipeline is the backbone of ASP.NET Core, handling incoming HTTP requests and generating appropriate responses. It is configured using middleware components. Middleware Middleware components process requests and responses, adding functionality like authentication, logging, and routing. They form a chain that each request passes through. Controllers and Views Controllers handle application logic, interacting with models and selecting views to render UI. Views are Razor pages that define the structure and content of web pages. Routing Routing defines how URLs are mapped to controllers and actions, enabling clean and organized navigation throughout the application. Custom routes can be configured to meet specific needs.
  • 5.
    Creating a NewASP.NET Core Project Open Visual Studio Launch Visual Studio and click on "Create a new project" to start building your first ASP.NET Core application. Select ASP.NET Core Web App (MVC) Choose the "ASP.NET Core Web App (Model-View-Controller)" template to create a project that follows the MVC architectural pattern. Configure Project Settings Enter a project name, choose a location, and configure any additional settings before clicking "Create" to set up your project. Project Setup Wait for Visual Studio to complete the project setup, which includes generating the necessary files and dependencies for your ASP.NET Core application.
  • 6.
    Understanding Project Structure Controllers The"Controllers" folder contains the logic for handling HTTP requests. Each controller is a class that manages interactions and data flow for specific features. Views The "Views" folder stores Razor pages (.cshtml files) responsible for UI rendering. Views use HTML and C# code to display dynamic content. Models The "Models" folder represents data structures used in the application. Models define the properties and behavior of the data being managed. wwwroot The "wwwroot" folder stores static files like CSS, JavaScript, and images. These files are directly served to the client browser.
  • 7.
    Hands-on Activity: Modifyingthe Homepage 1 Open Index.cshtml Navigate to Views > Home > Index.cshtml to access the homepage view file. 2 Modify the Heading Change the <h1> heading to "Welcome to My First ASP.NET Core App!" to customize the page title. 3 Save and Run Save the changes and run the project to see the updated homepage in your web browser.
  • 8.
    Adding a NewController and Action Method Add Controller 1 Create Method 2 Save and Run 3 Go to the Controllers folder, right-click, and select Add > Controller. Choose MVC Controller - Empty and name it HelloController.cs. Add an action method named Greet that returns "Hello, ASP.NET Core!". Save and run the application, then navigate to /Hello/Greet to view the result. using Microsoft.AspNetCore.Mvc; namespace MyApp.Controllers { public class HelloController : Controller { public IActionResult Greet() { return Content("Hello, ASP.NET Core!"); } } }
  • 9.
    Q&A and Homework Q&ASession • Project structure • Controller-view interaction • Purpose of routing Take the time to ask questions about the project structure, how controllers and views interact, and the purpose of routing. Your questions will make sure everyone is ready for the homework assignment. Homework Assignment 1. Create UserController 2. Add Profile action 3. Modify Index.cshtml The homework assignment is to create a new controller called UserController, add an action method Profile that returns "User Profile Page", and modify Index.cshtml to include a link to /User/Profile.