Running the application

Before we jump in and run the application, let's make sure our new page is easily accessible. The simplest way to do that is to just set it as the default home page:

  1. Have a look at the Configure method in Startup.cs. You'll notice that the default route is specified as the Home controller.
  2. Simply change the controller to your Research controller as follows:
app.UseMvc(routes => 
{ 
    routes.MapRoute( 
        name: "default", 
        template: "{controller=Researches}/{action=Index}/{id?}"); 
});
  1. Lastly, make sure that your Main method looks as follows:
public static void Main(string[] args){  var host = BuildWebHost(args);  using (var scope = host.Services.CreateScope())  {    var services = scope.ServiceProvider;    try    { var context = services.GetRequiredService<ResearchContext>(); ...

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.