Command-controlled listening address and environment variables after ASP.

Source: Internet
Author: User

Add Command Support

To create a new ASP. NET Core project, open Program.cs Add the following code:

public class Program{    public static void Main(string[] args)    {        BuildWebHost(args).Run();    }    public static IWebHost BuildWebHost(string[] args) =>        WebHost.CreateDefaultBuilder(args)            .UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build())            .UseStartup<Startup>()            .Build();}

The main thing is this code:UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build())

Publish Project

Publish a dotnet publish -c Release project by command

Specifying the listening address and environment variables

We're going to start running.dotnet WebApplication1.dll

We can see that the default listener address is http://localhost:5000 , the default environment variable isProduction

We can --server.urls 监听地址 create a listening address by --environment 环境变量 specifying the environment variable

Like what:dotnet WebApplication1.dll --server.urls http://*:8080 --environment Staging

Reference: https://www.cnblogs.com/linezero/p/aspnetcorekestrelurls.html

Command-controlled listening address and environment variables after ASP.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.