title: ASP.NET Core 2.0 Razor Pages using AddMvcCore() instead of AddMvc()
body: <p>I'm not a big fan of using the pre-bundled <code>AddMvc()</code> and prefer to use the <code>AddMvcCore()</code> instead.</p>
  
  <p>Having said that, I was wondering how to go about using the new (as of 2.0) <code>AddRazorPages()</code> with <code>AddMvcCore()</code>.</p>
  
  <p>For example, if we do a "bare-bones" configuration of middleware to only use <code>AddRazorPages()</code> which is found from the <a href="https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs" rel="nofollow noreferrer">official repository</a></p>
  
  <pre><code>// loaded the NuGet package Microsoft.AspNetCore.Mvc.RazorPages
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvcCore()
          .AddRazorPages();
  }
  </code></pre>
  
  <p>After I created a <code>foo.cshtml</code> page and placed it into the <code>.\Pages\</code> directory, it is returning a 404 (Page not found) when I navigate to the URL <code>\Foo</code>.</p>
  
  <p><strong>.\Pages\Foo.cshtml</strong></p>
  
  <pre><code>@page
  @model IndexModel
  @using Microsoft.AspNetCore.Mvc.RazorPages
  
  @functions {
      public class IndexModel : PageModel
      {
          public string Message { get; private set; } = "In page model: ";
  
          public void OnGet()
          {
              Message += $" Server seconds  { DateTime.Now.Second.ToString() }";
          }
      }
  }
  
  &lt;h2&gt;Hello World&lt;/h2&gt;
  &lt;p&gt;
      @Model.Message
  &lt;/p&gt;
  </code></pre>
  
  <p>The sample page above is taken from the <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/razor-pages/?tabs=visual-studio" rel="nofollow noreferrer">Microsoft Documents: Introduction to Razor Pages in ASP.NET Core</a></p>
  
  <blockquote>
    <p>Has anyone figured this out, or know what is missing? I'm thinking there is an issue with the routing.</p>
  </blockquote>