ASP.NET Crash Course
Introduction
- Instructor: Chad Sluter, Professor of Computer Science and Software Development at Grand Canyon University.
- Course duration: Approximately 1 hour.
- Objective: Build a database-driven web application using ASP.NET Core and C#.
- Application to be built: A CRUD jokes app (Create, Read, Update, Delete operations).
Course Overview
- ASP.NET Core: Microsoft's open-source framework for building web applications.
- MVC Pattern: Model, View, Controller design for separating application concerns.
- Database Setup: Registration, login, and page security.
- Audience: Intermediate programmers familiar with C#, object-oriented programming, databases, SQL, HTML, CSS, and JavaScript.
ASP.NET Core and Its Relevance
- Developed by Microsoft to build web applications with C#.
- Competitors include Java Spring, PHP Laravel, and Python Flask.
- ASP.NET is used in enterprise-level applications and can lead to well-paying jobs.
- .NET Framework: Microsoft's platform for various types of applications, similar to Java's virtual machine.
- Active Server Pages (ASP): Dynamic web pages running on servers.
- Core: Open-source, cross-platform version of ASP.NET, supporting Linux, Mac, and Windows.
Building a Jokes Application
Application Overview
- The application allows users to manage jokes with a database.
- Features include listing, searching, adding, editing, and deleting jokes.
- Users must log in to create or edit jokes.
Setup and Project Creation
Tools Used
- Visual Studio on Windows.
- Project type: ASP.NET Core Web Application with MVC.
- Authentication setup for individual user accounts.
Initial Setup
- Controllers and Views: Home and Privacy pages are pre-generated.
- Models: Data classes representing application data.
Models, Views, and Controllers (MVC)
Models
- Classes that define the structure of data.
- Example:
Joke class with properties Id, JokeQuestion, JokeAnswer.
Views
- Web pages using Razor syntax to dynamically display data.
- Example: Creating forms for user input and displaying lists of data.
Controllers
- Handle logic and user requests.
- Example:
HomeController and JokesController handling respective actions.
Database Interaction
Migrations and Entity Framework
- Migrations: Used to create and update the database based on model changes.
- Entity Framework: ORM for database operations without writing SQL.
- Steps: Enable migrations, add migration, update database.
Application Features
CRUD Operations
- Create, Read, Update, Delete jokes using generated views and controllers.
Security and Authentication
- Use
[Authorize] attribute to restrict access to certain actions (e.g., creating jokes).
Navigation and UI
- Modify
Layout view to add navigation links for jokes and search.
Search Functionality
- Create a search form and method in the
JokesController to filter jokes.
CSS and Styling
- Customize appearance using
site.css.
- Optionally use Bootstrap for styling.
Conclusion
- Comprehensive overview of developing an ASP.NET Core application.
- Encouragement to explore further job opportunities with the skills gained.
- Final thoughts by Chad Sluter, encouraging further learning and application of these skills.
This course is a solid introduction to ASP.NET Core, useful for developing enterprise-level web applications, and provides foundational knowledge for further exploration in software development.