I'm trying to set things up for the first time in a .Net Core ASP 3.1 Application.
My ReportsController appears to be recognized properly (the constructor is called with the IReportServiceConfiguration) and the client attempts to call:
api/reports/resources/js/telerikReportViewer (with a ?_=<number> on the end)
But i'm getting this error:
"Message": "An error has occurred.","ExceptionMessage": "An item with the same key has already been added. Key: Cache-Control"
Full:
{
"Message": "An error has occurred.","ExceptionMessage": "An item with the same key has already been added. Key: Cache-Control","ExceptionType": "System.ArgumentException","StackTrace": " at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\r\n at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)\r\n at Microsoft.AspNetCore.HttpSys.Internal.HeaderCollection.Add(String key, StringValues value)\r\n at Telerik.Reporting.Services.AspNetCore.ReportsControllerBase.GetResourceCore(String folder, String resourceName, Type type)\r\n at Telerik.Reporting.Services.AspNetCore.ReportsControllerBase.GetResource(String folder, String resourceName)\r\n at lambda_method(Closure , Object , Object[] )\r\n at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"
}
9 Answers, 1 is accepted

Hello Ben,
I provided an answer in the support ticket #1456298. Since the cause of the issue is not yet determined, I will not paste here my answer. As soon as we are sure what the problem is, I will update the current forum thread so it will be useful for all the developers that might hit the same problem.
Regards,
Ivan Hristov
Progress Telerik

Hi,
I had the same error reason but not the same error message, only when we tried to display a report.
This is the error:
{
"message":"An error has occurred.",
"exceptionMessage":"An item with the same key has already been added.",
"exceptionType":"System.ArgumentException","stackTrace":" at
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowDuplicateKeyException()\r\n at
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.System.Collections.Generic.IDictionary<
System.String
,Microsoft.Extensions.Primitives.StringValues>.Add(String key, StringValues value)\r\n at
Telerik.Reporting.Services.AspNetCore.ReportsControllerBase.GetResourceCore(String folder, String resourceName, Type type)\r\n at
Telerik.Reporting.Services.AspNetCore.ReportsControllerBase.GetResource(String folder, String resourceName)\r\n at
lambda_method(Closure , Object , Object[] )\r\n at
Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)\r\n at
Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()\r\n at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n at
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()"
}
In our code I found a line where we added the "Cache-Control" header on application startup:
context.Response.Headers.Append(
"Cache-Control"
,
"no-cache"
);
The error seems to be that the Telerik Reporting also tries to add the same response header. When it exists the error occures. After removing our line everything works fine.
@Ben
It may help only to add the header if it still does not exist!?
if
(!context.Response.Headers.ContainsKey(
"Cache-Control"
)) { add header ... }



Hi Ben,
thanks for your fast reply and info that the error has been fixed. Great.
So the fix must be in Version 14.1.20.513 cause I am using the previous unpatched version 14.0.20.219 right now. I'll try the patch next time.
Hi all,
Just wanted to confirm that the issue with the Cache-Control key is fixed in internal build 14.0.20.325. Of course, the fix is also included in the R2 2020, which was released yesterday. You're more than welcome to download it, give it a try and share your thoughts.
Regards,
Ivan Hristov
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.

Hello Ivan,
yes, I can also confirm that the issue is fixed now, thank you. We just updated to 14.1.20.513 today.
Regards!
Hello Christian,
Thanks for confirming that the fix works in your scenario.
Regards,
Ivan Hristov
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.