title: Using Antiforgery with Ajax or AngularJs
body: <p>I installed Microsoft.AspNetCore.Antiforgery my asp.net core .net framework application, add to the configure services</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);
    services.AddTransient&lt;ISession, JwtSession&gt;(s =&gt; JwtSession.Factory());
    //services.AddCors();
    services.AddAntiforgery(options =&gt; options.HeaderName = "X-XSRF-TOKEN");
    services.AddMvc();
  }
  </code></pre>
  
  <p>I want to use it in a controller and did as follow:</p>
  
  <pre><code>    [Route("[action]"), Route("")]
      [HttpGet]
      public IActionResult Index()
      {
        var f = _antiforgery.GetAndStoreTokens(HttpContext);
        return View();
      }
  </code></pre>
  
  <p>But do not know how to put the key into view.</p>