How to Create Asp.Net Core MVC WEB Application using empty template?
Today here we are going to create Asp.Net Core MVC aka Model View Controller using empty template in asp.net core 2.2.0
- At first we need to open visual studio
- Left click on File
- Select New =>Project and you will see this type of popup as shown below:
- Now extend Visual C# at left side below new project
- Now click on Web and it will again extend and you will see .Net Core and click on .Net Core
- Select Asp.Net Core Web Application as shown in figure and select name and give name for your project and click Ok and in next step you will see next pop up window as shown below
- Now select .Net Core from left most dropdown
- Select Asp.Net core 2.2 on next drop down
- Select No Authentication from Authentication button
- And click Ok
- Now you see the empty project as shown below
- Now it’s time to add MVC on the empty project
- Now click on startup.cs and add MVC on ConfigureServices as shown in figure below
- So add
Services.AddMvc();
- On Configure Services
- Now add middleware and default route of MVC on Configure as shown below
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
- Now add Models and controller folder and add controller class on controller folder as shown below
- Now add View for Index
- Right click on Index and you will see popup window as shown below
- Select View name
- Select empty (without model) on Template and click on Add button
- Now you will see Index View page scaffolding as show below
Now run the program by clicking IIs Express Run and you will see index view run on your browser