
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

Jan 28, 2020 · 8 min read
Warum IP-Adressen kein eindeutiges Merkmal sind
Immer wieder sieht man in Code, der für den Login eines Benutzers verwendet wird, dass mit Hilfe der IP-Adresse oder zum Beispiel auch dem …

Oct 04, 2019 · 2 min read
Using ASP.NET Core 3 in .NET libraries
With the release of ASP.NET Core 3, Microsoft has also changed the way how to use and reference ASP.NET Core dependencies. In the past you …

Mar 26, 2017 · 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.
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.

Comments