Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed C# sample to use .NET Core 3.0 and more lean and secure alpin…
…e as base image (#1816) * Changed C# sample to use more lean and secure alpine as base image * Updated sample to use .NET Core 3.0 * Fixed typos in README.md * Fixed indentation
- Loading branch information
1 parent
1acf133
commit 187ed5a
Showing
5 changed files
with
51 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
docs/serving/samples/hello-world/helloworld-csharp/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
using System; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace helloworld_csharp | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateWebHostBuilder(args).Build().Run(); | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) | ||
public static IHostBuilder CreateHostBuilder(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); | ||
return Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>().UseUrls(url); | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 3 additions & 10 deletions
13
docs/serving/samples/hello-world/helloworld-csharp/helloworld-csharp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<RootNamespace>helloworld_csharp</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |