Журнал настраиваемых полей IIS через HTTP-запрос в ASP NET Core - PullRequest
10 голосов
/ 26 сентября 2019

Я включил ведение журнала IIS с настраиваемыми полями для своего веб-сайта.

enter image description here

Ранее в MVC я использовал HTTPHandlers и Module для добавления вышеуказанных полей в заголовки HTTP-запроса.

web.config:

 <modules runAllManagedModulesForAllRequests="true">
     <!--Handler to process the IIS logs of the site Pagevisit logs-->
    <add name="IISLogger" type="MySite.Website.MvcApplication.Utils.IISLogHandler, MySite.Website.MvcApplication" />
</modules>

IISLogHandler класс:

public class IISLogHandler : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        private void context_BeginRequest(object sender, EventArgs e)
        {
              var request = (sender as HttpApplication).Request;
              request.Headers["IIID"] = iiid;
              request.Headers["IID"] = !string.IsNullOrEmpty(customerId) ? 
               customerId : iid;

        }
}

Мой сгенерированный журнал:

enter image description here

Как перенести это на ASPNET Core 2.2.0?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...