ASP.NET Core – MVC – Bootstrap – Responsive Web Programming – Lecture 2: Views and Controllers



ASP.NET Core – MVC – Bootstrap – Responsive Web Programming – Lecture 2: Views and Controllers

ASP.NET Core - MVC - Bootstrap - Responsive Web Programming - Lecture 2: Views and Controllers

Join Discord For Help : https://bit.ly/CodeInNetDiscord. Lecture 2/17 of ASP.NET Core MVC with C# Programming Full Course. If I have been of assistance to you and you would like to show your support for my work, please consider becoming a patron on 🥰 https://www.patreon.com/SECourses

Source code repository of this Course:
https://github.com/FurkanGozukara/Responsive-Web-Design-With-ASP.NET-5-and-MVC-Pattern-and-BootStrap-5-2021

Playlist of this course: ASP.NET Core MVC Full Course – C# And BootStrap Version – Responsive Web #PROGRAMMING With Tutorials 👨‍💻 (FREE) – 2023:
https://www.youtube.com/playlist?list=PLdCdTIJgqkdFQ8pEZLZLsQIbze1KNEqWA,

#ASPNETCORE #WebDevelopment

In Lecture 2:
* In depth learning of Razor syntax
* How to define variables in Views (cshtml)
* How to write mixed HTML and C# code in views
* How to use foreach, if, else, for, while, switch in Views with Razor syntax
* How to compose custom classes in an ASP.NET MVC Core application and utilize them inside Views
* How to define local methods and use them inside Views
* How to define dynamic templated delegates and use them inside Views for printing easily HTML formatted data
* Templated delegate vs methods inside Views
* What are ViewData and ViewBag
* What is the difference between ViewData and ViewBag
* How to use ViewData and ViewBag to transfer data from Controller to the View
* What are MVC Controllers
* What are Actions in MVC Controllers
* How does default routing matches controllers and actions
* What are the action types such as HttpPost and HttpGet
* How to call different actions inside MVC controllers

ASP.NET Core MVC is a powerful framework that enables developers to create scalable and high-performance web applications. Razor syntax is a key feature of ASP.NET Core MVC that enables the creation of dynamic and interactive views. In this document, we will discuss various aspects of Razor syntax, how to define variables in Views, how to write mixed HTML and C# code in views, how to use different control structures like foreach, if, else, for, while, switch in Views with Razor syntax, how to compose custom classes in an ASP.NET MVC Core application, and utilize them inside Views. We will also discuss how to define local methods and use them inside Views, how to define dynamic templated delegates, and use them inside Views for printing easily HTML formatted data. We will also cover the difference between templated delegates and methods inside Views, and what ViewData and ViewBag are, and how to use them to transfer data from the Controller to the View. Furthermore, we will also discuss MVC Controllers, Actions in MVC Controllers, and the different types of actions, such as HttpPost and HttpGet.

Razor Syntax:

Razor is a markup syntax that enables developers to combine HTML and C# code seamlessly. Razor syntax provides a simple and easy-to-learn syntax that allows developers to create views in a natural way. Razor syntax is simple to use, and developers can use it to create dynamic and interactive views.

Defining Variables in Views:

Variables in Views can be defined using the @ symbol. For instance, to define a variable in a View, we can use the following syntax:

@{
var myVariable = “Hello, world!”;
}

Mixed HTML and C# code in Views:

Razor syntax allows for the mixing of HTML and C# code in Views. This enables the creation of dynamic and interactive views.

Control Structures in Views with Razor Syntax:

Razor syntax provides a variety of control structures that can be used to create complex views. These include foreach, if, else, for, while, and switch statements.

Composing Custom Classes and Using Them in Views:

In ASP.NET Core MVC, custom classes can be created and used in Views. These classes can be used to encapsulate complex logic and data, making it easier to create views that are easier to understand and maintain.

Defining Local Methods and Using Them Inside Views:

Local methods can be defined inside Views using Razor syntax. These methods can be used to encapsulate complex logic and data, making it easier to create views that are easier to understand and maintain.

Defining Dynamic Templated Delegates and Using Them Inside Views:

Dynamic templated delegates can be defined and used inside Views. These delegates can be used to print easily HTML formatted data.

Templated Delegates vs. Methods Inside Views:

Templated delegates and methods inside Views serve a similar purpose, but templated delegates are more flexible and can be used to print easily HTML formatted data.

ViewData and ViewBag:

ViewData and ViewBag are used to transfer data from the Controller to the View. These mechanisms provide a way to share data between the Controller and the View.

The Difference between ViewData and ViewBag:

ViewData and ViewBag serve a similar purpose, but ViewBag is a more dynamic approach and is less type-safe than ViewData.

Using ViewData and ViewBag to Transfer Data from Controller to View:

Comments are closed.