Dotnet - Hello World
Running a WebApp in 5min ?
ASP.NET Tutorial - Hello World in 5 minutes
in a Language you never touched before … ? a Microsoft App running on Linux running in Docker running on macOS … ?
Let’ give a try …
Fireup Ubuntu via Docker, do Port Forward
docker run -it -p 5123:5123 --name dotnet-hello ubuntu:latest
add basics
apt-get update && apt-get -y upgrade && apt-get -y install wget
add dotnet
wget https://packages.microsoft.com/config/ubuntu/22.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb
apt-get update && apt-get install -y dotnet-sdk-7.0
dotnet --version
build webapp
dotnet new webapp -o MyWebApp --no-https -f net7.0
run webapp, change IP & Port
cd MyWebApp
sed -i 's#"applicationUrl".*#"applicationUrl": "http://0.0.0.0:5123",#' Properties/launchSettings.json
dotnet watch
Hello World
Let’s try again and measure time
The Question was, if it is possible to run the Sample App in less than 5min. We have to check that again.
Fireup Docker
docker run -it -p 5123:5123 --name dotnet-hello ubuntu:latest
around 2 seconds
Build App
time (apt-get update && apt-get -y upgrade && apt-get -y install wget && \
wget https://packages.microsoft.com/config/ubuntu/22.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb && \
apt-get update && apt-get install -y dotnet-sdk-7.0 && \
dotnet new webapp -o MyWebApp --no-https -f net7.0 && \
cd MyWebApp && \
sed -i 's#"applicationUrl".*#"applicationUrl": "http://0.0.0.0:5123",#' Properties/launchSettings.json)
real 0m47.210s
user 0m21.984s
sys 0m10.527s
Run the App
dotnet watch
around 5 seconds
Summary
is it possible to run a ASP.NET App in 5min ?
Yes, it is!
When everythings is prepared and working. You’re familiar with Docker, can do Port Forwarding, know that localhost on Docker is not reachable from Outside even with Port forward … you can even bring it down below 1min. Including Download Ubuntu from Docker, Patch it, Download and Install Dotnet, build the sample app an run it.
No, it is not!
I spent half an hour to get everything working fine. Without even look at the Code. Not talking about repeating it 5 x for writing the Summary and do the final Speedtest.
Last but not least
do not forget to cleanup you env. Stop the docker, and kill the Image …
- CTRL-C to stop the Webapp
- exit to exit Docker
- docker rm dotnet-hello to remove the Container
Happy Hacking !
Any Comments ?
sha256: 931eda2b6f7717987dd600cc4cfe5e697889b5df21e0bcfbbde68b9f5e55ba84