How to enable/disable HTTP/HTTPS and Change Port No in ASP.NET Core 6? (2024)

How do we enable or disable HTTP or HTTPS or change the Kestrel port number in asp.net core 6 after we run the dotnet publish? There are several ways on the internet but mainly for during development e.g.

  1. Change applicationUrl and sqlPort in Properties/launchSettings.json.
  2. If using Visual Studio, change in Project Properties > Debug tab > Web Server Settings.
  3. Comment out app.UseHttpsRedirection(); in Program.cs and etc…

But these seems unable to work if we use dotnet publish and .NET 6. Luckily there is few settings in appsettings.json for us to solve the issue. Example settings are below:

{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "Kestrel": { "Endpoints": { "Http": { "Url": "http://localhost:5000" }, "Https": { "Url": "https://localhost:5001" } } }}

If we want to disable HTTP for the asp.net code, we just need to remove lines 11 to 13 and the same for HTTPS, if we want to disable HTTPS, just remove lines 14 to 16 and comment out app.UseHttpsRedirection(); in Program.cs.

If we want to change the port number, we just change in the Http and Https there according. By default, the port number will be 5000 for Http and 5001 for Https.

Below is an example result if disable Http and change Https port to 5005:

info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:5005info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.info: Microsoft.Hosting.Lifetime[0] Hosting environment: Productioninfo: Microsoft.Hosting.Lifetime[0] Content root path: /dotnet/razorapp/bin/Release/net6.0/publish/

References:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-5.0
https://stackoverflow.com/questions/50935730/how-do-i-disable-https-in-asp-net-core-2-1-kestrel

How to enable/disable HTTP/HTTPS and Change Port No in ASP.NET Core 6? (2024)
Top Articles
Convert Google Play Balance or Credits into Cash | DesiDime
Can someone tell if I block their number?
9.4: Resonance Lewis Structures
What to Do For Dog Upset Stomach
Identifont Upload
Arkansas Gazette Sudoku
Sarah F. Tebbens | people.wright.edu
Marist Dining Hall Menu
Midway Antique Mall Consignor Access
Robot or human?
Hartford Healthcare Employee Tools
Https E24 Ultipro Com
104 Whiley Road Lancaster Ohio
Busby, FM - Demu 1-3 - The Demu Trilogy - PDF Free Download
Golden Abyss - Chapter 5 - Lunar_Angel
Dover Nh Power Outage
Quick Answer: When Is The Zellwood Corn Festival - BikeHike
Great Clips Grandview Station Marion Reviews
Rs3 Ushabti
Olivia Maeday
Www Pointclickcare Cna Login
Cal State Fullerton Titan Online
Vht Shortener
Black Lion Backpack And Glider Voucher
Play It Again Sports Forsyth Photos
Tu Housing Portal
Kleinerer: in Sinntal | markt.de
Pay Stub Portal
United E Gift Card
Inmate Search Disclaimer – Sheriff
Abga Gestation Calculator
Craigslist Cars And Trucks Mcallen
Advance Auto Parts Stock Price | AAP Stock Quote, News, and History | Markets Insider
Greater Keene Men's Softball
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Woodman's Carpentersville Gas Price
The Minneapolis Journal from Minneapolis, Minnesota
What Does Code 898 Mean On Irs Transcript
Ukraine-Krieg - Militärexperte: "Momentum bei den Russen"
Mybiglots Net Associates
Wgu Admissions Login
The Sports Academy - 101 Glenwest Drive, Glen Carbon, Illinois 62034 - Guide
Dobratz Hantge Funeral Chapel Obituaries
All Buttons In Blox Fruits
Barback Salary in 2024: Comprehensive Guide | OysterLink
St Als Elm Clinic
Unpleasant Realities Nyt
Rocket Bot Royale Unblocked Games 66
Hy-Vee, Inc. hiring Market Grille Express Assistant Department Manager in New Hope, MN | LinkedIn
Vt Craiglist
All Obituaries | Roberts Funeral Home | Logan OH funeral home and cremation
login.microsoftonline.com Reviews | scam or legit check
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated:

Views: 5551

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.