I'm trying to redirect HTTP to HTTPS for my Blazor application, I follow all the steps that listed in THIS microsoft documentation and THIS question's answers but unfortunately when I try to run my application the browser redirect me to https://192.168.1.147/ and getting error:
This site can't be reached
The VS code says:
Connecting to the browser is taking longer than expected .
Here's the steps that I applied to Program.cs in the server project:
Settings for redirect HTTP to HTTPS in Startup.cs:
builder.Services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect; options.HttpsPort = 443; }); Add the following configuration:
if (app.Environment.IsDevelopment()){ app.UseWebAssemblyDebugging();}else{ app.UseExceptionHandler("/Home/Error"); app.UseHsts(); //This}app.UseHttpsRedirection(); //ThisEdit launchSettings.json by adding SSL Port, this is the full content:
{"profiles": {"APPlicationName.Server": {"commandName": "Project","launchBrowser": true,"environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" },"dotnetRunMessages": true,"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}","applicationUrl": "http://192.168.1.147:1241" },"IIS Express": {"commandName": "IISExpress","launchBrowser": true,"environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" },"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}" } },"iisSettings": {"windowsAuthentication": false,"anonymousAuthentication": true,"iisExpress": {"applicationUrl": "http://192.168.1.147:1241","sslPort": 443 } }}What's my mistake?