This is a sample app, trying to demonstrate the smallest ASP.NET Core Minimal API, a "Hello World!" example. The Program.cs* is only three lines of code.
Program.cs:
var app = WebApplication.CreateBuilder(args).Build();
app.MapGet("/", () => "Hello World!");
app.Run();
Expand to see *Sample.cspoj* and *launchSettings.json* files
Sample.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
Properties/launchSettings.json:
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7263;http://localhost:5029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Note The appsettings.json file is optional
Run the app:
@IEvangelist , would you mind throwing up and linking to a Gist of, say, the smallest possible
launchSettings.json
to go with this? Thus far, I've got this as aProgram.cs
and<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net6.0</TargetFramework><Nullable>enable</Nullable><LangVersion>preview</LangVersion><ImplicitUsings>true</ImplicitUsings><RootNamespace>MinimalAPI</RootNamespace></PropertyGroup></Project>
as aMinimalAPI.csproj
but I'm stuck figuring out what to put forlaunchSettings.json
, which is my best guess why, when I publish this 2-file repo to platform.sh, it gives me a "live" URL hosted on their servers, but visiting the URL 502's out.(I know, I know, I'm supposed to be using the "dotnet" CLI to scaffold things out for me. I'm petulant and refuse to use boilerplate I don't understand and insist on doing this the hard way, adding teeny-tiny files by hand until it runs.)
Thanks!