0

I have more than one app running in a IIS and I get the following error:

The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the configuration specifies explicit encryption and validation keys.

That occurs when I open a web app, for example http://localhost:90 and logging into it. Later, I open a second tab (http://localhost:91) and logging into the web app. After that, I return to the first tab and press Log Off (or any other post to any other form) and I get the error.

  • There isn't more than one AntiForgeryToken in the same views
  • I tried to configure individual MachineKeys in the web apps and I couldn't resolve it (from the IIS and from the web.config too).
Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
  • Is it the same web application on both ports? – Tasos K. Oct 12 '18 at 16:21
  • Differents web applications in differents ports – Claudio Saccella Oct 12 '18 at 16:24
  • I tried to reproduce it, but what happened was that if I logged out from one application, I was automatically logged out from the other one. Cookies are per domain, so for example, if you created a custom cookie in http://localhost:90, this will be available in http://localhost:91 as well.My guess is that session cookies get mixed between applications. – Tasos K. Oct 12 '18 at 18:27
  • You have different application pool for each application? And deploy them to IIS or run the apps from VS? You configure different Machine Keys for each app ? – Claudio Saccella Oct 12 '18 at 21:02
  • Anyway, thanks you for ur help. I find that the problem could be caused by the shared cookies as you say. – Claudio Saccella Oct 12 '18 at 21:08
  • 1
    I run the apps in IIS. They have the same Machine Key and that's probably why I didn't get the error as in your scenario. – Tasos K. Oct 12 '18 at 21:18
  • I run the apps in IIS but I configure individual machine keys for each app – Claudio Saccella Oct 12 '18 at 21:39

0 Answers0