Add Response Headers to ASP.NET Core Middleware

前端 未结 6 1326
轻奢々
轻奢々 2020-12-08 06:40

I want to add a processing time middleware to my ASP.NET Core WebApi like this

public class ProcessingTimeMiddleware  
{
    private readonly RequestDelegate         


        
6条回答
  •  無奈伤痛
    2020-12-08 07:15

    On a related note, without answering your question as such, there is now a Server-Timing specification, a standard header to provide durations, amongst other metrics. This should allow you to use

    Server-Timing: processingTime;dur=12ms
    

    You can find the specification at https://www.w3.org/TR/server-timing/

提交回复
热议问题