antiforgerytoken

.net Core 2.0 web api 400 error using Validateantiforgerytoken

ぃ、小莉子 提交于 2021-02-10 06:19:12
问题 I have two .Net Core applications, a Web API and Client. Sending Post from the client using : <form asp-action="Create" method="post"> @Html.AntiForgeryToken() ..... </form> Client controller: public async Task<IActionResult> Create([Bind("QuestionId,TheQuestion")] SecurityQuestion securityQuestion) { _session.SetString(SessionsKeys.Directory, "/SecurityQuestions"); if (ModelState.IsValid) { var data = await _theService.PostWebApi(securityQuestion); if (data.Item3 == "True") { return

An exception was thrown while deserializing the token.The antiforgery token could not be decrypted in .Net Core 2.2 application

旧巷老猫 提交于 2021-02-08 15:08:03
问题 I am getting the error in my log. I spent most of my day finding the solution but could not find the one which meets my requirement. Here is the log error severity=[ERROR], ipaddress=xxxx, subprocess=Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery, description=An exception was thrown while deserializing the token. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted. ---> System.Security.Cryptography.CryptographicException:

Anti forgery token and web testing

末鹿安然 提交于 2021-02-06 11:53:36
问题 I am trying to do a web test in VS2012 for an MVC site. One of the scenarios is to login and go through a list of products, select the one you want and follow through to the purchase page. Problem is that when the web test is run, I get an error about the anti forgery token and that it does not match. How on earth is it possible to do the testing with the anti forgery token? The user must login - there will be thousands of users for the load test (eventually) but need to make it work for 1

Using Antiforgery in ASP.NET Core and got error - the antiforgery token could not be decrypted

℡╲_俬逩灬. 提交于 2020-08-21 05:29:40
问题 My ASP.Net Core MVC application have added Antiforgery middleware like below: startup.cs services.AddMvc(); services.AddSession(); services.AddCaching(); services.AddSession(o => { o.IdleTimeout = TimeSpan.FromMinutes(120); }); services.AddAntiforgery(); I've added below in the view and controller View: <form action="/Home/Login" method="post" id="staff-login" autocomplete="off"> @Html.AntiForgeryToken() ...... Controller [HttpPost, ValidateAntiForgeryToken] public IActionResult Login

Using Antiforgery in ASP.NET Core and got error - the antiforgery token could not be decrypted

柔情痞子 提交于 2020-08-21 05:29:22
问题 My ASP.Net Core MVC application have added Antiforgery middleware like below: startup.cs services.AddMvc(); services.AddSession(); services.AddCaching(); services.AddSession(o => { o.IdleTimeout = TimeSpan.FromMinutes(120); }); services.AddAntiforgery(); I've added below in the view and controller View: <form action="/Home/Login" method="post" id="staff-login" autocomplete="off"> @Html.AntiForgeryToken() ...... Controller [HttpPost, ValidateAntiForgeryToken] public IActionResult Login

ValidateAntiForgeryToken in Ajax request with AspNet Core MVC

只愿长相守 提交于 2020-08-01 10:24:05
问题 I have been trying to recreate an Ajax version of the ValidateAntiForgeryToken - there are many blog posts on how to do this for previous versions of MVC, but with the latest MVC 6, none of the code is relevant. The core principle that I am going after, though, is to have the validation look at the Cookie and the Header for the __RequestVerificationToken , instead of comparing the Cookie to a form value. I am using MVC 6.0.0-rc1-final, dnx451 framework, and all of the Microsoft.Extensions

ValidateAntiForgeryToken in Ajax request with AspNet Core MVC

筅森魡賤 提交于 2020-08-01 10:23:16
问题 I have been trying to recreate an Ajax version of the ValidateAntiForgeryToken - there are many blog posts on how to do this for previous versions of MVC, but with the latest MVC 6, none of the code is relevant. The core principle that I am going after, though, is to have the validation look at the Cookie and the Header for the __RequestVerificationToken , instead of comparing the Cookie to a form value. I am using MVC 6.0.0-rc1-final, dnx451 framework, and all of the Microsoft.Extensions

ValidateAntiForgeryToken in Ajax request with AspNet Core MVC

半世苍凉 提交于 2020-08-01 10:21:34
问题 I have been trying to recreate an Ajax version of the ValidateAntiForgeryToken - there are many blog posts on how to do this for previous versions of MVC, but with the latest MVC 6, none of the code is relevant. The core principle that I am going after, though, is to have the validation look at the Cookie and the Header for the __RequestVerificationToken , instead of comparing the Cookie to a form value. I am using MVC 6.0.0-rc1-final, dnx451 framework, and all of the Microsoft.Extensions

Angular 6 and AutoValidateAntiforgeryToken

三世轮回 提交于 2020-07-10 08:08:32
问题 I have searched a lot but i don't find how to implement the AutoValidateAntiforgeryToken. I'm creating an Angular 6 spa with TypeScript, connecting to an endpoint .NET Core 2.1 In ConfigureServices added services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); before AddMvc() added in Configure app.Use(next => context => { string path = context.Request.Path.Value; if (string.Equals(path, "/", StringComparison.OrdinalIgnoreCase) || string.Equals(path, "/index.html",

Angular 6 and AutoValidateAntiforgeryToken

╄→尐↘猪︶ㄣ 提交于 2020-07-10 08:07:20
问题 I have searched a lot but i don't find how to implement the AutoValidateAntiforgeryToken. I'm creating an Angular 6 spa with TypeScript, connecting to an endpoint .NET Core 2.1 In ConfigureServices added services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); before AddMvc() added in Configure app.Use(next => context => { string path = context.Request.Path.Value; if (string.Equals(path, "/", StringComparison.OrdinalIgnoreCase) || string.Equals(path, "/index.html",