https://github.com/dotnet/aspnetcore/blob/39f0e0b8f40b4754418f81aef0de58a9204a1fe5/src/Mvc/Mvc.Core/src/StatusCodeResult.cs#L1
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Mvc; /// <summary> /// Represents an <see cref="ActionResult"/> that when executed will /// produce an HTTP response with the given response status code. /// </summary> public partial class StatusCodeResult : ActionResult, IClientErrorActionResult { /// <summary> /// Initializes a new instance of the <see cref="StatusCodeResult"/> class /// with the given <paramref name="statusCode"/>. /// </summary> /// <param name="statusCode">The HTTP status code of the response.</param> public StatusCodeResult([ActionResultStatusCode] int statusCode) { StatusCode = statusCode; } /// <summary> /// Gets the HTTP status code. /// </summary> public int StatusCode { get; } int? IStatusCodeActionResult.StatusCode => StatusCode; /// <inheritdoc /> public override void ExecuteResult(ActionContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var httpContext = context.HttpContext; var factory = httpContext.RequestServices.GetRequiredService<ILoggerFactory>(); var logger = factory.CreateLogger<StatusCodeResult>(); Log.HttpStatusCodeResultExecuting(logger, StatusCode); httpContext.Response.StatusCode = StatusCode; } private static partial class Log { [LoggerMessage(1, LogLevel.Information, "Executing StatusCodeResult, setting HTTP status code {StatusCode}", EventName = "HttpStatusCodeResultExecuting")] public static partial void HttpStatusCodeResultExecuting(ILogger logger, int statusCode); } }
分类:
netcore
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2017-11-20 串口通信,帧与帧之间的时间间隔问题?9600波特率,帧将各在20ms以上