mirror of https://github.com/knative/docs.git
serving/helloworld-csharp: respect the port env var (#462)
This commit is contained in:
parent
224ef9c272
commit
3935463648
|
@ -17,8 +17,13 @@ namespace helloworld_csharp
|
|||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>().UseUrls("http://0.0.0.0:8080");
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
string port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
|
||||
string url = String.Concat("http://0.0.0.0:", port);
|
||||
|
||||
return WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>().UseUrls(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,17 @@ recreate the source files from this folder.
|
|||
```
|
||||
|
||||
1. Update the `CreateWebHostBuilder` definition in `Program.cs` by adding
|
||||
`.UseUrls("http://0.0.0.0:8080")` to define the serving port:
|
||||
`.UseUrls()` to define the serving port:
|
||||
|
||||
```csharp
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>().UseUrls("http://0.0.0.0:8080");
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
string port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
|
||||
string url = String.Concat("http://0.0.0.0:", port);
|
||||
|
||||
return WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>().UseUrls(url);
|
||||
}
|
||||
```
|
||||
|
||||
1. Update the `app.Run(...)` statement in `Startup.cs` to read and return the
|
||||
|
|
Loading…
Reference in New Issue