// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.AspNetCore.Antiforgery.IAntiforgery antiforgery) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); //app.Use(next => httpContext => //{ // AntiforgeryTokenSet tokenSet = antiforgery.GetAndStoreTokens(httpContext); // httpContext.Response.Cookies.Append( // "MY-TOKEN", // tokenSet.RequestToken, // new CookieOptions() { HttpOnly = false } // ); // return next(httpContext); //}); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Ledger}/{action=Index}/{id?}"); }); }
public string GetToke([FromServices] Microsoft.AspNetCore.Antiforgery.IAntiforgery antiforgery) { var token = antiforgery.GetAndStoreTokens(HttpContext).RequestToken; return(token); }