-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStartup.fs
65 lines (51 loc) · 2.47 KB
/
Startup.fs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace EFCore.FSharp.AuthMvc
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Identity
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.HttpsPolicy;
open Microsoft.AspNetCore.Mvc
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Microsoft.EntityFrameworkCore
open EFCore.FSharp.AuthMvc.Data
type Startup private () =
new (configuration: IConfiguration) as this =
Startup() then
this.Configuration <- configuration
// This method gets called by the runtime. Use this method to add services to the container.
member this.ConfigureServices(services: IServiceCollection) =
let connectionString = this.Configuration.GetConnectionString "DefaultConnection"
services.AddDbContext<ApplicationDbContext>(fun options ->
options.UseSqlServer(connectionString) |> ignore
) |> ignore
services.AddDatabaseDeveloperPageExceptionFilter() |> ignore
services
.AddDefaultIdentity<IdentityUser>(fun options -> options.SignIn.RequireConfirmedAccount <- true)
.AddEntityFrameworkStores<ApplicationDbContext>() |> ignore
// Add framework services.
services.AddControllersWithViews().AddRazorRuntimeCompilation() |> ignore
services.AddRazorPages() |> ignore
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
member this.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) =
if (env.IsDevelopment()) then
app.UseDeveloperExceptionPage() |> ignore
else
app.UseExceptionHandler("/Home/Error") |> ignore
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts() |> ignore
app.UseHttpsRedirection() |> ignore
app.UseStaticFiles() |> ignore
app.UseRouting() |> ignore
app.UseAuthentication() |> ignore
app.UseAuthorization() |> ignore
app.UseEndpoints(fun endpoints ->
endpoints.MapControllerRoute(
name = "default",
pattern = "{controller=Home}/{action=Index}/{id?}") |> ignore
endpoints.MapRazorPages() |> ignore) |> ignore
member val Configuration : IConfiguration = null with get, set