-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathStartup.cs
44 lines (41 loc) · 1.33 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using myximblockwallet.org.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace myximblockwallet.org
{
public class Startup
{
public Startup(IConfiguration configuration) => Configuration = configuration;
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton<XimBlockNode>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Home/Error");
app.Use(async (context, next) =>
{
if (context.Request.IsHttps)
await next();
else
context.Response.Redirect("https://" + context.Request.Host + context.Request.Path);
});
app.UseStaticFiles();
app.UseMvc(routes =>
{
//https://stackoverflow.com/questions/12828317/mvc-4-remove-home-from-base-route
routes.MapRoute("OnlyAction", "{action}", new { controller = "Home", action = "Index" });
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
}
}