title: How do I map an endpoint to a static file in ASP. NET Core?
body: <p>I am building a single page web application in ASP .NET Core which requires me to map some URLs to an endpoint which serves a specific static file called "index.html".</p>
  
  <p>Currently, I used a hack solution which maps <strong>all</strong> URLs to the endpoint.</p>
  
  <pre><code>_ = app.UseEndpoints(endpoints =&gt; {
      _ = endpoints.MapControllers();
  
      _ = endpoints.MapGet("/test", async context =&gt; {
          // I need some way to serve the static file in the response
          await context.Response.WriteAsync("Hello world");
      });
  
      // TODO replace with actual endpoint mapping
      //_ = endpoints.MapFallbackToFile("index.html");
  });
  </code></pre>
  
  <p>Instead, I would like to map only a specific set of URLs to the endpoint. How do I accomplish this?</p>