Skip to content

Instantly share code, notes, and snippets.

@sonicparke
Last active May 7, 2017 17:40
Show Gist options
  • Save sonicparke/cd015786076767ecc5881cddbd2547ec to your computer and use it in GitHub Desktop.
Save sonicparke/cd015786076767ecc5881cddbd2547ec to your computer and use it in GitHub Desktop.
Setting Up the Angular CLI in Visual Studio for Mac
using System.IO;
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection(“Logging”));
loggerFactory.AddDebug();
app.Use(async (context, next) =>
{
await next();
// If there’s no available file and the request doesn’t contain an extension, we’re probably trying to access a page.
// Rewrite request to use app root
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value) && !context.Request.Path.Value.StartsWith(“/api”))
{
context.Request.Path = “/index.html”;
context.Response.StatusCode = 200; // Make sure we update the status code, otherwise it returns 404
await next();
}
});
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment