title: How do I set a default home page in ASP.NET Core 2?
body: <p>I am having some difficulty configuring a default home page in an ASP.NET MVC Core 2 application. I seem to be unable to get the routing to map to the correct home page a the default when no parameters are used, ex. <a href="https://localhost:44362" rel="noreferrer">https://localhost:44362</a></p>
  
  <p>I don't really like the default convention of putting Controllers in a Controllers folder, view in Views, and View Models in Models. I prefer to group by feature.</p>
  
  <p>So I have a structure like this:</p>
  
  <pre><code>Features
     Home
        HomeController.cs
        HomeIndex.cshtml
        HomeViewModel.cs
     Other
        OtherController.cs
        OtherIndex.cshtml
        OtherViewModel.cs
  </code></pre>
  
  <p>Everything works fine, except I can't seem to get the default page to be /Home/Index when no path is provided. Everything worked when HomeController was in Controllers (and Index in Views/Home), but as soon as I moved it, things broke.</p>
  
  <p>I'm using the default Startup.cs file, so I have a Configure method that looks like this:</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseBrowserLink();
          app.UseDeveloperExceptionPage();
          app.UseDatabaseErrorPage();
      }
      else
      {
          app.UseExceptionHandler("/Home/Error");
      }
  
      app.UseStaticFiles();
  
      app.UseAuthentication();
  
      app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              name: "default",
              template: "{controller=Home}/{action=Index}/{id?}");
      });
  }
  </code></pre>
  
  <p>I did some searching it and it looks like using this in the ConfigureServices method should work:</p>
  
  <pre><code>services.AddMvc().AddRazorPagesOptions(options =&gt;
  {
      options.Conventions.AddPageRoute("", "/Home/Index");
  });
  </code></pre>
  
  <p>That throws a: Value cannot be null or empty (pageName) exception. I also tried "/", "/Home/Index" as parameters. Finally, just for good measure, I also swapped the above parameters just in case I was misunderstanding usage of each parameter.</p>
  
  <p>In every case, no page is displayed. If I enter the full URL /Home/Index, it works. I also tried to attach a [Route("Home")] attribute to the HomeController class and a [Route("Index")] to the action method.</p>
  
  <p>So I'm obviously messed up the routing, but it's not at all clear to me how to fix this. I've read and re-read the docs on Razor Pages which doesn't seem to clear up my understanding.</p>