DotNETCore 学习笔记 宿主】的更多相关文章

Hosting -------------------------------------------------------------------------- Setting up a Host : using Microsoft.AspNetCore.Hosting; public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .…
API Description Request body Response body GET /api/todo Get all to-do items None Array of to-do items GET /api/todo/{id} Get an item by ID None To-do item POST /api/todo Add a new item To-do item To-do item PUT /api/todo/{id} Update an existing item…
Razor Syntax Reference Implicit Razor expressions <p>@DateTime.Now</p> <p>@DateTime.IsLeapYear()</p> <p>@await DoSomething("hello", "world")</p> Explicit Razor expressions <p>Last week ))</p…
Dependency Injection ------------------------------------------------------------------------ ASP.NET services can be configured with the following lifetimes: Transient Transient lifetime services are created each time they are requested. This lifeti…
Configuration var builder = new ConfigurationBuilder(); builder.AddInMemoryCollection(); var config = builder.Build(); config["somekey"] = "somevalue"; // do some other work var setting = config["somekey"]; // also returns &q…
Logging --------------------------------------------------------------------------------------- Implementing Logging in your Application var logger = loggerFactory.CreateLogger("Catchall Endpoint"); logger.LogInformation("No endpoint found…
Globalization and localization **************************************************************************************************** using Microsoft.AspNet.Localization; using Microsoft.AspNet.Mvc.Localization; namespace Localization.StarterWeb.Contro…
Error Handling public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseIISPlatformHandler(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } public static void HomePage(IApplicationBuilder app) { app.Run(async (…
Route ------------------------------------------constraint---------------------------------------------------- routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default&…
Application Startup Startup Constructor - IHostingEnvironment - ILoggerFactory ConfigureServices - IServiceCollection Configure - IApplicationBuilder - IHostingEnvironment - ILoggerFactory -------------------------------------------------------------…