
Dieser Artikel stammt aus dem Jahr 2016. Versionen, Werkzeuge und Empfehlungen können sich seitdem geändert haben. Neuere Beiträge findest du unter ASP.NET Core.
Hello world
Hier ein vollständiges und minimales Beispiel, wie eine simple Hello World Anwendung in ASP.NET Core 1 aussehen kann:
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5using Microsoft.AspNetCore.Builder;
6using Microsoft.AspNetCore.Hosting;
7using Microsoft.AspNetCore.Http;
8using Microsoft.Extensions.DependencyInjection;
9using Microsoft.Extensions.Logging;
10
11namespace AspNetCore_Basics_HelloWorld
12{
13 public class Program
14 {
15 public static void Main(string[] args)
16 {
17 var host = new WebHostBuilder()
18 .UseKestrel()
19 .UseStartup<Startup>()
20 .Build();
21
22 host.Run();
23 }
24 }
25
26 public class Startup
27 {
28 public void ConfigureServices(IServiceCollection services)
29 {
30 }
31 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory lf)
32 {
33 loggerFactory.AddConsole();
34
35 if (env.IsDevelopment())
36 {
37 app.UseDeveloperExceptionPage();
38 }
39
40 app.Run(async (context) =>
41 {
42 await context.Response.WriteAsync("Hello World!");
43 });
44 }
45 }
46}Related articles

- 1 min read
Better exception details with ASP.NET Core
By default, ASP.NET Core suppresses Exceptions on Startup on external environments. So you only get Exceptions in Startup on localhost.

- 2 min read
ASP.NET Core - Teil 2: die Middleware
Bereit bei ASP.NET 4 konnte man mit Hilfe von OWIN - Open Web Interface for .NET - Middleware-Implementierungen sehr einfach und robust …

- 3 min read
ASP.NET Core - Teil 1: die Basics
Seit Ende Juni steht ASP.NET Core 1 als RTM zur Verfügung - und es erfreut sich großer Beliebtheit! In diesem mehrteiligen Beitrag möchte …
Let's Work Together
Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.
