title: How to turn off Application insights javascript in embedded cshtml views
body: <p>I have a view Email1.cshtml (Build Action=Embedded Resource):</p>
  
  <pre><code>@model Email1Model;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Hello, @Model.Name&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I render the cshtml view to string using <a href="https://gist.github.com/ieski/f868df128a58b69f95ab78d60c1bc0a4" rel="nofollow noreferrer">ViewRenderService</a>. The only difference is that I use <code>IRazorViewEngine.GetView()</code> instead of FindView();</p>
  
  <p>However, in the output I some application insights stuff:</p>
  
  <pre><code>&lt;html&gt; &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          var appInsights=window.appInsights||function(config){....);
  
          window.appInsights=appInsights;
          appInsights.trackPageView();
  
      &lt;/script&gt; &lt;/head&gt; &lt;body&gt;
      &lt;h1&gt;Hello, Liero&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt;
  </code></pre>
  
  <p>In the startup.cs:</p>
  
  <pre><code>services.AddApplicationInsightsTelemetry(opt =&gt; opt.InstrumentationKey = appInsightsKey);
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>How do I turn off the javascript in specific views that I render using ViewRenderService?</p>