Popular Posts
-
I would like to bring another one of my skills to the table, WordPress baby! Starting with this post I will be covering the basics, doma...
-
Whenever a website is made you have to pay for the host and domain. There are different payment plans, sometimes every month and sometim...
-
re: purchasing WordPress.COM upgrades WordPress.com provides free blogs and hosts them free of charge. There are no bandwidth charges. A...
-
ASPHostPortal.com - The leader of ASP.NET hosting provider launches ASP.NET 4.6 hosting with fast network and fast support. New York, ...
-
CrowdReviews.com Announces Guide for Selecting Web Hosting Companies SOURCE: CrowdReviews.com July 23...
-
Grandi expresses his gratitude to Kenya for hosting almost half a million refugees and keeping its borders open to people fleeing war. B...
-
danroo 6 hours ago Template 59 Views HostWHMCS is a Responsive Web Hosting and WHMCS Template designed for All kinds of Domain an...
-
HOSTIO is a readymade web hosting WordPress theme for immediate use — created as straight forward as it can be. It's built with mode...
-
Introduction With .NET Core 1.0 fresh off the press, the Windows developer in me that has a decade-long experience with C# is thrilled by...
-
April 28, 2016 04:00 ET | Source: Research and Markets Dublin, April 28, 2016 (GLOBE NEWSWIRE) -- Research and Markets has announ...
Blog Archive
- December (19)
- November (25)
- October (28)
- September (26)
- August (28)
- July (31)
- June (26)
- May (27)
- April (28)
- March (30)
- February (28)
- January (31)
- December (31)
- November (30)
- October (31)
- September (29)
- August (44)
- July (56)
- June (53)
- May (54)
- April (48)
- March (55)
- February (44)
- January (3)
- December (5)
- November (5)
- October (26)
- September (25)
- August (29)
- July (26)
- June (18)
- September (1)
About Me
Total Pageviews
Web Host Builder in ASP.NET Core 2.0
I want to share something from the first chapter of my upcoming book Front-end Development with ASP.NET Core, Angular, and Bootstrap.
While reviewing and updating the code from ASP.NET Core 1.0 to version 2.0 I was faced with the challenge of how to explain what's going on in the initialization of the WebHostwhich was made much more simple and logical in ASP.NET Core 2.0 but at the cost of being more "magical."
But let's get back to basics a bit. The initialization happens inside two files:
The ASP.NET Core 2.x the initialization of the WebHost in the Program.cs file is just a few lines of code:
public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build(); }And the code in the Startup.cs file is exactly just about configuring the request execution pipeline.
public class Startup { public void ConfigureServices(IServiceCollection services) { } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); } }But now you don't really understand what has happened. Especially if you have worked with ASP.NET Core 1.x where everything was much more verbose and explicit.
I bet you would be surprised to know that after this 3 lines of code you have:
In ASP.NET Core 1.x, you had to specify everything explicitly, even adding references to a few additional Nuget packages.
All these configurations are hidden inside the CreateDefaultBuilder method. To understand better what's going on I recommend you go on the ASPNET/MetaPackages git repo and read its implementation.
How do you like this new approach? I personally like it as it declutters the code and removes all plumbing code from what is supposed to be just the creation of the execution pipeline of your application. But I admit it made my job of explaining what happens behind the scenes more difficult.
Node.js application metrics sent directly to any statsd-compliant system. Get N|Solid
Topics:
web dev ,asp.net core 2.0 ,web hosting
Source: Web Host Builder in ASP.NET Core 2.0
Thanks for the always useful information. This is great information to help peoples and nice article written by writer. CnX Player is a powerful & efficient 4K ultra HD enabled video player for Windows 10 PC & Tablet, Android and iOS – iPhone & iPad.
ReplyDeleteDownload Media Player for Windows 10 - Microsoft Store
Download Video Player for Android from Google Play
Download Video Player for iPhone/iPad from Apple App Store