This project is read-only.


Multiple database calls to revalidate cookie



I am new to the world so it's possible I am doing something wrong but this situation looks really weird to me. When I set validateInterval: TimeSpan.FromMinutes(0) when configuring app.UseCookieAuthentication
so I can force propagation of roles in every request I notice that I get additional 10 database calls every request.

Steps to reproduce:

1 - Create a brand new MVC project. (visual studio 2015 latest updates using identity 2.2.1)
2 - Go to Startup.Auth.cs and change validateInterval: TimeSpan.FromMinutes(30) to validateInterval: TimeSpan.FromMinutes(0).
3 - Call HomeController and notice that there is no database call.
4 - Create a new user and login in.
5 - Call HomeController and notice that there is 10 calls being made to the database every request.

Is this normal or is there a way to avoid it?


file attachments

Closed Sep 15, 2016 at 8:47 PM by bdorrans


bdorrans wrote Sep 15, 2016 at 8:46 PM

This is normal. In 2.x it takes a few queries to get enough information to recreate the identity and drop the cookie. And by setting the validateInterval to 0 that's what you're forcing to happen on every request.

nikko1337 wrote Sep 16, 2016 at 4:14 AM

I understand it needs a few queries but is it normal to increase as I add MVC bundles for example? In the example above I am having 10 queries sent. If I add another bundle it goes to 20 queries and so on. These could easily result in a huge amount of queries being sent to get the same data everytime.

bdorrans wrote Sep 16, 2016 at 5:48 PM

I don't understand what you mean by "add MVC bundles". Could you explain?