Here are the steps to add MVC to your application:
1. Open the Startup.cs file, then in "ConfigureServices" method type in the following to enable MVC
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
2. As with the static files, there will be a red underline on the .AddMvc() method that's because we haven't added the package to your project yet. So click on the yellow light and select the first option to add Microsoft.AspNET.Mvc package to our project.
3. Now go into the Configure method and type app.UseMvc() into the method, the final markup should look like the following
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseMvc();
}
Even though we have enabled MVC in our application we haven't configure any routes for it. We will do that in the next post. Stay tuned!
ASP.NET Core Posts:
No comments:
Post a Comment