Skip to content

Commit

Permalink
Merge Startup.cs logic into Program.cs. (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Frederik Prijck <[email protected]>
  • Loading branch information
LayersOfAbstraction and frederikprijck committed Mar 13, 2023
1 parent 0423f60 commit 6abe396
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 74 deletions.
56 changes: 40 additions & 16 deletions Quickstart/Sample/Program.cs
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();
58 changes: 0 additions & 58 deletions Quickstart/Sample/Startup.cs

This file was deleted.

0 comments on commit 6abe396

Please sign in to comment.