I have made a boilerplate .net 5.0 react SPA (I didnt do anything to it, literally just the boilerplate from dotnet), and then tried to publish it to Azure devops. I have created the app service, and the sql database and everything seemed to work, however I get a 500 status error when I try to load the page, saying the page cannot handle the request. I have the logs attached here, perhaps someone can make some better sense of this and let me know what I am missing? It seems like something to do with signing credentials, and I don't even know what that is at this point. I think I am really in over my head but really want to learn.
Edit: Added the startup file
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SpaTest.Data;
using SpaTest.Models;
namespace SpaTest {
public class Startup {
public Startup( IConfiguration configuration ) {
Configuration = configuration;
}
public IConfiguration Configuration {
get;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices( IServiceCollection services ) {
services.AddDbContext<ApplicationDbContext>( options =>
options.UseSqlServer(
Configuration.GetConnectionString( "DefaultConnection" ) ) );
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddDefaultIdentity<ApplicationUser>( options => options.SignIn.RequireConfirmedAccount = true )
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
services.AddAuthentication()
.AddIdentityServerJwt();
services.AddControllersWithViews();
services.AddRazorPages();
// In production, the React files will be served from this directory
services.AddSpaStaticFiles( configuration => {
configuration.RootPath = "ClientApp/build";
} );
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure( IApplicationBuilder app, IWebHostEnvironment env ) {
if ( env.IsDevelopment() ) {
app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint();
} else {
app.UseExceptionHandler( "/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.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints( endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}" );
endpoints.MapRazorPages();
} );
app.UseSpa( spa => {
spa.Options.SourcePath = "ClientApp";
if ( env.IsDevelopment() ) {
spa.UseReactDevelopmentServer( npmScript: "start" );
}
} );
}
}
}