diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f83a0d9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/src/bin/Debug/netcoreapp2.2/AdvantageTool.dll", + "args": [], + "cwd": "${workspaceFolder}/src", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..fd544db --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/AdvantageTool.csproj b/src/AdvantageTool.csproj index 287d61b..b7a8e23 100644 --- a/src/AdvantageTool.csproj +++ b/src/AdvantageTool.csproj @@ -1,17 +1,23 @@  - netcoreapp2.2 + netcoreapp3.1 aspnet-AdvantageTool-BDEADEA1-8829-4850-A527-CD895CA0BCC1 /subscriptions/8f07513f-af9b-45df-8f7e-a791be4685d3/resourcegroups/LTI/providers/microsoft.insights/components/AdvantageTool /subscriptions/8f07513f-af9b-45df-8f7e-a791be4685d3/resourcegroups/LTI/providers/microsoft.insights/components/AdvantageTool - - - - + + + + + + + + + + diff --git a/src/Areas/Identity/Pages/Account/Register.cshtml.cs b/src/Areas/Identity/Pages/Account/Register.cshtml.cs index e73e9a8..a7561b8 100644 --- a/src/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/src/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -62,7 +62,7 @@ public void OnGet(string returnUrl = null) public async Task OnPostAsync(string returnUrl = null) { - returnUrl = returnUrl ?? Url.Content("~/"); + returnUrl ??= Url.Content("~/"); if (ModelState.IsValid) { var user = new AdvantageToolUser { UserName = Input.Email, Email = Input.Email }; diff --git a/src/Program.cs b/src/Program.cs index 9e1de65..ed35b94 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -11,8 +11,6 @@ public static void Main(string[] args) } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseApplicationInsights() - .UseStartup(); + WebHost.CreateDefaultBuilder(args).UseStartup(); } } diff --git a/src/Startup.cs b/src/Startup.cs index 22ef0da..905c6c5 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -8,6 +8,7 @@ using AdvantageTool.Utility; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace AdvantageTool { @@ -58,20 +59,24 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc() .AddRazorPagesOptions(options => options.Conventions.AuthorizeFolder("/Platforms")) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddHttpClient(); + services.AddApplicationInsightsTelemetry(); + services.AddHealthChecks(); + // Make AccessTokenService available for dependency injection. services.AddTransient(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseMigrationsEndPoint(); app.UseDatabaseErrorPage(); } else @@ -85,7 +90,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); - app.UseMvc(); + + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => + { + endpoints.MapHealthChecks("/healthcheck"); + endpoints.MapRazorPages(); + }); } } }