title: Application Insights – Capture ASMX WebMethod Names code not getting triggered
body: <p>In one of my assignment have to get web service method name in application insight.</p>
  
  <p>i referenced below link<br>
    <a href="https://unhandled.wordpress.com/2018/02/11/application-insights-capture-asmx-webmethod-names-invoked/" rel="nofollow noreferrer">https://unhandled.wordpress.com/2018/02/11/application-insights-capture-asmx-webmethod-names-invoked/</a></p>
  
  <p>written below code in my class file.</p>
  
  <pre><code>public class ApplicationInsightsMethodLogInitializer: ITelemetryInitializer
      {
          public void Initialize(ITelemetry telemetry)
          {
              var requestTelemetry = telemetry as RequestTelemetry;
              string soapActionMethod = null;
              string requestMethodName = null;
              string webServiceMethod = null;
              var logger = Sitecore.DependencyInjection.ServiceLocator.ServiceProvider.GetService&lt;ILogger&gt;();
              logger.Info("HI Pradeep Here");
              // Is this a TrackRequest() ?
              if (requestTelemetry == null) return;
              requestMethodName = System.Web.HttpContext.Current.Request.Params["op"]; // Item("HTTP_SOAPACTION");
              if (requestMethodName == "" || requestMethodName == null)
              {
                  if (System.Web.HttpContext.Current.Request.PathInfo != null)
                  {
                      requestMethodName = System.Web.HttpContext.Current.Request.PathInfo;
                  }
                  if (requestMethodName != "" &amp;&amp; requestMethodName != null)
                  {
                      logger.Info("Got It..");
                      requestMethodName = requestMethodName.Replace("/", "");
                      // If we set the Success property, the SDK won't change it:
                      requestTelemetry.Success = true;
                      // Allow us to filter these requests in the portal:
                      requestTelemetry.Properties["WebMethodName"] = requestMethodName;
                      webServiceMethod = requestMethodName;
                  }
              }
              if (webServiceMethod != null)
              {
                  requestTelemetry.Context.Operation.Name = requestTelemetry.Context.Operation.Name.Replace("/" + webServiceMethod, "") + "/" + webServiceMethod;
              }
          }
  </code></pre>
  
  <p>Then register it in ApplicationInsights.config:</p>
  
  <pre><code> &lt;Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web"/&gt;
      &lt;Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web"/&gt;
      &lt;Add Type="GCC.Foundation.Analytics.ApplicationInsightsMethodLogInitializer, GCC.Foundation.Analytics" /&gt;
  </code></pre>
  
  <p>While running code, in class file that code is not getting triggered and debugger is also not hitting.</p>
  
  <p>Result should be like webserviceName/MethodName.</p>
  
  <p>i tried to call this code from explicit calls its running because class method is called.</p>
  
  <p>do i missed something in this, that's why ApplicationInsightsMethodLogInitializer is not getting triggered.</p>
  
  <p>In all scenario dependency call getting logged in app insight, but mine changes not coming.</p>
  
  <p>help me on this.</p>