DotNetCore 笔记】的更多相关文章

最近公司框架升级到DotNetCore了,但是在用post请求的时候,发现页面的post data后台并没有接收到数据,经过调查发现,netcore用法和之前的MVC5不一样,想要接收post里的data,就需要在写接口的入参增加个属性[FromBody] #region 发布订单 /// <summary> /// 发布订单 /// </summary> /// <param name="_PrivateOrderPostBody">订单</…
OS:Widows 10 IDE: VS2017 Docker:Docker Desktop for Windows Windows下安装Docker需要先启用Hyper-v 在Windows 容器的运行目录在C盘这个改不了,但是可以改image的保存路径 Desktop 右键 > Settings > Daemon > 点击 Basic > 输入 "graph": "D:\\docker\\images" 本地环境搭好后开始准备项目制作镜像…
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…
Hosting -------------------------------------------------------------------------- Setting up a Host : using Microsoft.AspNetCore.Hosting; public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .…
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 (…