Skip to content
This repository was archived by the owner on May 1, 2018. It is now read-only.

Commit afe7525

Browse files
author
loktionov_a
committed
[startup]: proxy request path
1 parent 258fa33 commit afe7525

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

WebApiServer/Startup.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Startup(IConfiguration configuration)
4747
/// </param>
4848
public void ConfigureServices(IServiceCollection services)
4949
{
50-
string connection = Configuration.GetConnectionString("DefaultConnection");
50+
var connection = Configuration.GetConnectionString("DefaultConnection");
5151
services.AddDbContext<Models.ApiContext>(options => options.UseSqlServer(connection));
5252
services.AddMvc();
5353
}
@@ -64,6 +64,18 @@ public void ConfigureServices(IServiceCollection services)
6464
// ReSharper disable once UnusedMember.Global
6565
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
6666
{
67+
app.Use(async (context, next) => {
68+
await next();
69+
70+
if (context.Response.StatusCode == 404
71+
&& !System.IO.Path.HasExtension(context.Request.Path.Value)
72+
&& !context.Request.Path.Value.StartsWith("/api/"))
73+
{
74+
context.Request.Path = "/index.html";
75+
await next();
76+
}
77+
});
78+
6779
app.UseDefaultFiles();
6880
app.UseStaticFiles();
6981

0 commit comments

Comments
 (0)