Creating .NET 6 MVC Project in Visual Studio | Lecture 6
This article will help you in understanding how .NET 6 MVC based project works
Table of contents
Video Lecture on topic:
Instant method of creating a project of .NET 6 with MVC is selecting the predefine template of ASP.NET Project with MVC which will provide you all the basic files and folders 📂 which are required to create and run a MVC project. It is completely loaded project template as you can see in the screenshot below.
This is good for the professional developers who are aware of all the basics of MVC so they can get all the basic files and start directly from their own code this help them in avoiding the process of defining complete architecture of MVC in a new project but being a noob it is important to start your work by defining the complete MVC architecture by yourself so you can understand how things are interlink into the project and what is the base of a project so I would recommend you to chose an empty project and define every thing by yourself.
You can chose the empty project from the option shown below in the screenshot.
Now in this empty project you have to define everything by yourself i.e. Controllers, Models and Views folder.
Under the Views Folder a Folder name Shared and few other files as shown in the video tutorial embedded in top of this article.
The Program.cs file of this empty project would not be same as the predefine MVC project so you have to define this class by yourself here complete program.cs class code is shared below
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMvc();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler();
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
app.Run();
Complete Tree of the Self define project
📦YouTubeNET6Series
┣ 📂Controllers
┃ ┗ 📜HomeController.cs
┣ 📂Models
┣ 📂Views
┃ ┣ 📂Home
┃ ┃ ┣ 📜Index.cshtml
┃ ┃ ┗ 📜Welcome.cshtml
┃ ┣ 📂Shared
┃ ┃ ┗ 📜_Layout.cshtml
┃ ┣ 📜_ViewImports.cshtml
┃ ┗ 📜_ViewStart.cshtml
┣ 📂wwwroot
┃ ┣ 📂css
┃ ┗ 📂images
┣ 📜appsettings.Development.json
┣ 📜appsettings.json
┣ 📜Program.cs
More detail understanding I would highly recommend you to go through the Video lecture of this topic.