Bad Request - Header Field Too Long Error

lawrence whittemore asked on February 10, 2022 20:06

I am trying to pass the current AD user info into SignInManger and it seems to be fidning the user and creating the cookie, but when the site reloads I get a "Bad Request - Header Field Too Long Error" I can see the site created 7 or so cookies called identity.authentication the main one and 7 chunks....

any thoughts on what would cause this? If i delete teh cookies it goes away for a second but once the cookies are recreated it comes back.

Recent Answers


vasu yerramsetti answered on February 11, 2022 02:27

lawrence whittemore answered on February 11, 2022 13:48

I've googled around and have found how to clear it, but it happens everytime I load the site. Something about the cookies that are being created is the issue.

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on February 11, 2022 14:57

So, I figured out what was happeneing. The identity.authentication cookie contains all of the users roles. Our organization has like 80 million roles assigned to each user and they were all being put into the cookie causing it to be way to big. I removed all the roles and was able to get it to work.

Any thoughts on why it does it this way?

0 votesVote for this answer Mark as a Correct answer

vasu yerramsetti answered on February 12, 2022 08:06

I am not sure how much big your website. Normally one user not assigned to 80 million roles. Please check the business logic on the following -

  1. User registration logic
  2. User login logic
0 votesVote for this answer Mark as a Correct answer

Eugene Paden answered on February 16, 2022 21:47

hi Lawrence,

the reason why the authentication cookie includes all the roles for a user is so you can use that for AUTHORIZATION purposes.

if you don't need the roles, just don't pass it back in the list of claims sent with the token.

0 votesVote for this answer Mark as a Correct answer

Craig Wyatt answered on February 18, 2022 14:16

Clearing it is fine, but it happens every time the page loads when the site creates the authentication cookie. The problem, is our organization uses a lot of AD groups and those are turned into roles in kentico. When the site creates the cookie it includes all the roles assigned to the user as part of it which causes the issue, I've deleted all the AD roles that are created, but that may be an issue if our organization decided that they want us to use the AD groups for permissions. We'll probably just have to create a naming convention that we use specifically for the intranet and only import those.

0 votesVote for this answer Mark as a Correct answer

Ryan Hillier answered on April 11, 2022 08:09

Very useful information, I was also looking for a solution to a similar problem recently

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.