Last active
May 7, 2017 17:40
-
-
Save sonicparke/cd015786076767ecc5881cddbd2547ec to your computer and use it in GitHub Desktop.
Setting Up the Angular CLI in Visual Studio for Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
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