this directory contains a replica of
ASP.NET Core Docker Sample at commit 0fc0e2c6af6303cfd4676f1ac8c21090d82b0072 Update samples to .NET 6 with aspnetapp project from
ASP.NET Core Docker Container Sample for DigitalOcean App Platform added Elastic.Apm.NetCoreAll to dependenies, and to Startup.cs
- pull base images
docker pull mcr.microsoft.com/dotnet/runtime:6.0-alpine3.16-amd64docker image ls | grep mcr.microsoft.com/dotnet/runtimemcr.microsoft.com/dotnet/runtime 6.0-alpine3.16-amd64 532cc32c09d3 13 days ago 79.7MB
docker pull mcr.microsoft.com/dotnet/sdk:6.0-alpine3.16-amd64docker image ls | grep mcr.microsoft.com/dotnet/sdkmcr.microsoft.com/dotnet/sdk 6.0-alpine3.16-amd64 c5e11f288acd 13 days ago 604MB
docker pull mcr.microsoft.com/dotnet/aspnet:6.0-alpine-amd64- build
IMAGE=basic-aspnetapp
docker build -t $IMAGE -f Dockerfile .- test without APM
NAME=basic-aspnetapp
docker run --name $NAME -it -p 8000:80 $IMAGE- test with APM
NAME=basic-aspnetapp
ELK_NETWORK=basic-elk-cluster_elastic
docker run --name $NAME --network $ELK_NETWORK -it -p 8000:80 $IMAGEor
docker start $NAMEcurl -s http://localhost:8000 | grep Welcome<h1 class="display-4">Welcome to ASP.NET Core on DigitalOcean App Platform</h1>
- vanilla ASP .Net Core code aparently is a regular one - usage of statement Lambda operator indicates it's a 6.x C# not a 5.x compatible C#
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace aspnetapp {
public class Program {
public static void Main(string[] args) {
CreateHostBuilder(args).Build().Run(); }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(
webBuilder => { webBuilder.UseStartup<Startup>(); });
}
}- Some Microsoft example C# looks a bit excesively modern and resembles a VB.Net:
Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
var app = builder.Build();
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();The latter syntax change appears unnnecessary for such a basic app. Besides the code snippets and documentation on Elastic are written in C# 6.0
NAME=basic-aspnetapp
docker container stop $NAME
docker container rm $NAME
IMAGE=basic-aspnetapp
docker image rm $IMAGE* https://hub.docker.com/_/microsoft-dotnet-runtime/
* https://hub.docker.com/_/microsoft-dotnet-sdk/
* [C# language versioning](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version)
* what's new in [C# 9](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9)
* what's new in [C# 10](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10)
* what's new in [C# 11](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11)
* the four ways of [what ASP.NET Web Forms Really is beneath Server Controls](https://www.codeproject.com/articles/what-aspnet-web-forms-really-is-benea1768274267459)



