-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge Startup.cs logic into Program.cs. (#81)
Co-authored-by: Frederik Prijck <[email protected]>
- Loading branch information
1 parent
0423f60
commit 6abe396
Showing
2 changed files
with
40 additions
and
74 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Auth0.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using SampleMvcApp.Support; | ||
using System.Net; | ||
|
||
namespace SampleMvcApp | ||
using Microsoft.IdentityModel.Logging; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
//To use MVC we have to explicitly declare we are using it. Doing so will prevent a System.InvalidOperationException. | ||
builder.Services.AddControllersWithViews(); | ||
builder.Services.AddAuth0WebAppAuthentication(options => | ||
{ | ||
options.Domain = builder.Configuration["Auth0:Domain"]; | ||
options.ClientId = builder.Configuration["Auth0:ClientId"]; | ||
}); | ||
|
||
// Configure the HTTP request pipeline. | ||
builder.Services.ConfigureSameSiteNoneCookies(); | ||
var app = builder.Build(); | ||
|
||
if (!app.Environment.IsDevelopment()) | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
app.UseExceptionHandler("/Home/Error"); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseStaticFiles(); | ||
app.UseCookiePolicy(); | ||
|
||
app.UseRouting(); | ||
app.UseAuthentication(); | ||
app.UseAuthorization(); | ||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapDefaultControllerRoute(); | ||
}); | ||
|
||
app.Run(); |
This file was deleted.
Oops, something went wrong.