title: ASP.NET Core MVC requests return 404
body: <p>I created a quick project to prove a point and now well I guess I suck. For some reason I'm pulling 404 errors on an endpoint in this very simple site setup. I feel like I'm missing something minor but I can't seem to put my finger on it.</p>
  <p>Any assistance would be great, I really just can't seem to wrap my head around how the routes are being created and / or how the route that I'm attempting to use is invalid?</p>
  <p>I've only ever used the .NET framework, and .NET Core seems to be handling things slightly different.</p>
  <p>Originally, I had just made it a form targeting the asp-controller / asp-action with method=POST. However that didn't work and I received a 404 page.</p>
  <p>Then I tried using jQuery Ajax request, same result.</p>
  <p><strong>Startup.cs</strong></p>
  <pre><code>public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddControllersWithViews();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler(&quot;/Home/Error&quot;);
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
  
          app.UseStatusCodePagesWithReExecute(&quot;/Home/Error/{0}&quot;);
  
          app.UseHttpsRedirection();
          app.UseStaticFiles();
  
          app.UseRouting();
  
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapDefaultControllerRoute();
          });
      }
  }
  </code></pre>
  <p>Home controller:</p>
  <pre><code>public class HomeController : Controller
  {
      private readonly ILogger&lt;HomeController&gt; _logger;
  
      public HomeController(ILogger&lt;HomeController&gt; logger)
      {
          _logger = logger;
      }
  
      public IActionResult Index()
      {
          return View();
      }
  
      public IActionResult Privacy()
      {
          return View();
      }
  
      [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
      public IActionResult Error()
      {
          var model = new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier};
  
          if (Response.StatusCode.Equals(HttpStatusCode.NotFound))
              return View(&quot;~/Views/Shared/404.cshtml&quot;, model);
  
          return View(model);
      }
  
      [HttpPost]
      public async Task&lt;IActionResult&gt; DownloadAsync([FromBody] DownloadModel model)
      {
          try
          {
              var youtube = new YoutubeClient();
              var manifest = await youtube.Videos.Streams.GetManifestAsync(model.VideoId);
  
              var info = manifest.GetMuxed().WithHighestVideoQuality();
  
              if (info != null)
              {
                  var file = $&quot;{model.VideoId}.{info.Container}&quot;;
                  await youtube.Videos.Streams.DownloadAsync(info, file);
                  var bytes = await System.IO.File.ReadAllBytesAsync(file);
                  return File(bytes, &quot;application/force-download&quot;, file);
              }
          }
          catch (Exception e)
          {
              // TODO: Document Exception
              this._logger.LogError(e, $&quot;Download exception occurred.&quot;);
          }
  
          return BadRequest();
      }
  }
  </code></pre>
  <p><strong>Index.cshtml</strong></p>
  <pre><code>@model DownloadModel
  @{
      ViewData[&quot;Title&quot;] = &quot;Home Page&quot;;
  }
  
  &lt;div class=&quot;text-center&quot;&gt;
      &lt;h1 class=&quot;display-4&quot;&gt;Yipper (Youtube Ripper)&lt;/h1&gt;
      &lt;input type=&quot;text&quot; asp-for=&quot;Url&quot; class=&quot;url-input&quot; id=&quot;url-textbox&quot;/&gt;
      &lt;button id=&quot;url-submit-btn&quot; class=&quot;url-btn&quot; type=&quot;submit&quot;&gt;RIP&lt;/button&gt;
  &lt;/div&gt;
  
  @section Scripts
  {
      &lt;script&gt;
          function download(e) {
              e.preventDefault();
              const request = {
                  &quot;Url&quot;: $(&quot;#url-textbox&quot;).val() 
              }
              console.log(request);
              $.ajax('@Url.Action(&quot;DownloadAsync&quot;, &quot;Home&quot;)',
                  {
                      method: &quot;POST&quot;,
                      data: request
                  }).done(function(result) {
                      console.log(result);
                  }).fail(function(error) {
                      console.log(error);
                  });
          }
  
          $(function() {
              $(&quot;#url-submit-btn&quot;).click(download);
          });
      &lt;/script&gt;
  }
  </code></pre>