Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The required antiforgery cookie is not present error: When registering first user in new asp.net 5 project in Chrome only

I am using Visual Studio 2015 Enterprise and my dnx version is the latest (rc1-update 1). When I create a new web project from scratch with Individual User Accounts and I load the website and fill out the form to register the first user I instantly get the following error:

An unhandled exception occurred while processing the request.

InvalidOperationException: The required antiforgery cookie "9tyjs755shX" is not present.
Microsoft.AspNet.Antiforgery.DefaultAntiforgeryTokenStore.<GetRequestTokensAsync>d__4.MoveNext()

InvalidOperationException: The required antiforgery cookie "9tyjs755shX" is not present.

This has to be some kind of ASP.NET 5 bug because everything I am using is default and freshly installed. The error only happens when using Chrome browser. If anyone wants to reproduce simply create a new web app from scratch with individual user accounts, load the website in Chrome, try and register a user.

like image 300
Blake Rivell Avatar asked Mar 14 '23 17:03

Blake Rivell


2 Answers

One in the category of: "Have you tried turning it off and on again."

I've removed my browser history (cookies) and it now works.

How I found it: I tried it in Incognito mode and worked straight away without any code change.

like image 157
Tom Hofman Avatar answered Apr 26 '23 01:04

Tom Hofman


I just tried to reproduce your problem and cannot.

There are a couple of things to check;

  1. View the source of the login page and ensure the __RequestVerificationToken hidden field is present

  2. In Developer Tools look at Cookies under The resources tab. Look for a cookie which has a matching value for the __RequestVerificationToken field.

Both must be present.

like image 36
blowdart Avatar answered Apr 26 '23 01:04

blowdart