【问题标题】:logging request and response记录请求和响应
【发布时间】:2019-06-04 19:06:53
【问题描述】:

我必须捕获每个请求和响应的特定字段,并将详细信息发送到 asp.net 核心中的另一个 api。

我在下面的 github 链接 https://gist.github.com/elanderson/c50b2107de8ee2ed856353dfed9168a2 的帮助下创建了一个中间件 并在startup.cs类的cofigure方法中注册。

我怀疑代码 _logger.LogInformation(await FormatRequest(context.Request)) 将记录传入请求的位置? 如何将传入请求从中间件发送到 url?

【问题讨论】:

    标签: c# asp.net-core


    【解决方案1】:

    在中间件中的任何地方,您都可以使用

    进行重定向
            app.Run(async context =>
            {
                context.Response.Redirect("http://somepath");
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-10
      • 2023-04-02
      • 2016-05-01
      • 2021-07-21
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多