From 06d74d1658d52805cfe50c7ecfddd99621f88cf6 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 7 May 2023 08:58:11 -0700 Subject: [PATCH] Small tweaks to make the MVC application run locally --- src/Web/WebMVC/Program.cs | 6 +-- src/Web/WebMVC/Properties/launchSettings.json | 16 +------ src/Web/WebMVC/appsettings.json | 10 ++-- src/Web/WebMVC/globalusings.cs | 46 +++++++++---------- 4 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs index fff566c19..ce7d33208 100644 --- a/src/Web/WebMVC/Program.cs +++ b/src/Web/WebMVC/Program.cs @@ -63,7 +63,7 @@ static void AddHealthChecks(WebApplicationBuilder builder) { builder.Services.AddHealthChecks() .AddCheck("self", () => HealthCheckResult.Healthy()) - .AddUrlGroup(new Uri(builder.Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); + .AddUrlGroup(_ => new Uri(builder.Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); } static void AddCustomMvc(WebApplicationBuilder builder) @@ -85,7 +85,7 @@ static void AddCustomMvc(WebApplicationBuilder builder) // Adds all Http client services static void AddHttpClientServices(WebApplicationBuilder builder) { - builder.Services.AddSingleton(); + builder.Services.AddHttpContextAccessor(); //register delegating handlers builder.Services.AddTransient() @@ -116,7 +116,7 @@ static void AddCustomAuthentication(WebApplicationBuilder builder) var callBackUrl = builder.Configuration.GetValue("CallBackUrl"); var sessionCookieLifetime = builder.Configuration.GetValue("SessionCookieLifetimeMinutes", 60); - // Add Authentication services + // Add Authentication services builder.Services.AddAuthentication(options => { diff --git a/src/Web/WebMVC/Properties/launchSettings.json b/src/Web/WebMVC/Properties/launchSettings.json index bf529db40..cc41e62fe 100644 --- a/src/Web/WebMVC/Properties/launchSettings.json +++ b/src/Web/WebMVC/Properties/launchSettings.json @@ -1,23 +1,9 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:5100", - "sslPort": 0 - } - }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, "Microsoft.eShopOnContainers.WebMVC": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:5000", + "applicationUrl": "http://localhost:5331", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Web/WebMVC/appsettings.json b/src/Web/WebMVC/appsettings.json index 55561ef75..e0d07178a 100644 --- a/src/Web/WebMVC/appsettings.json +++ b/src/Web/WebMVC/appsettings.json @@ -1,8 +1,10 @@ { - "CatalogUrl": "http://localhost:5101", - "OrderingUrl": "http://localhost:5102", - "BasketUrl": "http://localhost:5103", - "IdentityUrl": "http://localhost:5105", + "PurchaseUrl": "http://localhost:5229", + "CatalogUrl": "http://localhost:5222", + "OrderingUrl": "http://localhost:5224", + "BasketUrl": "http://localhost:5221", + "IdentityUrl": "http://localhost:5223", + "IdentityUrlHC": "http://localhost:5223/hc", "CallBackUrl": "http://localhost:5100/", "IsClusterEnv": "False", "UseResilientHttp": "True", diff --git a/src/Web/WebMVC/globalusings.cs b/src/Web/WebMVC/globalusings.cs index aff8f2e62..1fe624e28 100644 --- a/src/Web/WebMVC/globalusings.cs +++ b/src/Web/WebMVC/globalusings.cs @@ -1,7 +1,24 @@ -global using HealthChecks.UI.Client; +global using System; +global using System.Collections.Generic; +global using System.ComponentModel; +global using System.ComponentModel.DataAnnotations; +global using System.IdentityModel.Tokens.Jwt; +global using System.IO; +global using System.IO.Compression; +global using System.Linq; +global using System.Net.Http; +global using System.Net.Http.Headers; +global using System.Security.Claims; +global using System.Security.Principal; +global using System.Text; +global using System.Text.Json; +global using System.Text.Json.Serialization; +global using System.Threading; +global using System.Threading.Tasks; +global using HealthChecks.UI.Client; +global using Microsoft.AspNetCore.Authentication; global using Microsoft.AspNetCore.Authentication.Cookies; global using Microsoft.AspNetCore.Authentication.OpenIdConnect; -global using Microsoft.AspNetCore.Authentication; global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Builder; global using Microsoft.AspNetCore.DataProtection; @@ -9,40 +26,21 @@ global using Microsoft.AspNetCore.Diagnostics.HealthChecks; global using Microsoft.AspNetCore.Hosting; global using Microsoft.AspNetCore.Http; global using Microsoft.AspNetCore.Identity; -global using Microsoft.AspNetCore.Mvc.Rendering; global using Microsoft.AspNetCore.Mvc; -global using Microsoft.AspNetCore; +global using Microsoft.AspNetCore.Mvc.Rendering; +global using Microsoft.eShopOnContainers.WebMVC; global using Microsoft.eShopOnContainers.WebMVC.Services; +global using Microsoft.eShopOnContainers.WebMVC.ViewModels; global using Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations; global using Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels; global using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels; global using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination; -global using Microsoft.eShopOnContainers.WebMVC.ViewModels; -global using Microsoft.eShopOnContainers.WebMVC; global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.Diagnostics.HealthChecks; global using Microsoft.Extensions.Hosting; global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Options; -global using Microsoft.IdentityModel.Logging; global using StackExchange.Redis; -global using System.Collections.Generic; -global using System.ComponentModel.DataAnnotations; -global using System.ComponentModel; -global using System.IdentityModel.Tokens.Jwt; -global using System.IO.Compression; -global using System.IO; -global using System.Linq; -global using System.Net.Http.Headers; -global using System.Net.Http; -global using System.Security.Claims; -global using System.Security.Principal; -global using System.Text.Json.Serialization; -global using System.Text.Json; -global using System.Text; -global using System.Threading.Tasks; -global using System.Threading; -global using System; global using WebMVC.Infrastructure; global using WebMVC.Services.ModelDTOs;