File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
serving/samples/helloworld-csharp Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,13 @@ public static void Main(string[] args)
1717 CreateWebHostBuilder ( args ) . Build ( ) . Run ( ) ;
1818 }
1919
20- public static IWebHostBuilder CreateWebHostBuilder ( string [ ] args ) =>
21- WebHost . CreateDefaultBuilder ( args )
22- . UseStartup < Startup > ( ) . UseUrls ( "http://0.0.0.0:8080" ) ;
20+ public static IWebHostBuilder CreateWebHostBuilder ( string [ ] args )
21+ {
22+ string port = Environment . GetEnvironmentVariable ( "PORT" ) ?? "8080" ;
23+ string url = String . Concat ( "http://0.0.0.0:" , port ) ;
24+
25+ return WebHost . CreateDefaultBuilder ( args )
26+ . UseStartup < Startup > ( ) . UseUrls ( url ) ;
27+ }
2328 }
2429}
Original file line number Diff line number Diff line change @@ -26,12 +26,17 @@ recreate the source files from this folder.
2626 ```
2727
28281. Update the ` CreateWebHostBuilder` definition in ` Program.cs` by adding
29- ` .UseUrls(" http://0.0.0.0:8080 " )` to define the serving port:
29+ `.UseUrls ()` to define the serving port:
3030
3131 ` ` ` csharp
32- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
33- WebHost.CreateDefaultBuilder(args)
34- .UseStartup<Startup> ().UseUrls(" http://0.0.0.0:8080" );
32+ public static IWebHostBuilder CreateWebHostBuilder(string[] args)
33+ {
34+ string port = Environment.GetEnvironmentVariable(" PORT" ) ?? " 8080" ;
35+ string url = String.Concat(" http://0.0.0.0:" , port);
36+
37+ return WebHost.CreateDefaultBuilder(args)
38+ .UseStartup<Startup> ().UseUrls(url);
39+ }
3540 ```
3641
37421. Update the ` app.Run(...)` statement in ` Startup.cs` to read and return the
You can’t perform that action at this time.
0 commit comments