# .NET core exception

**URL:** <https://discuss.elastic.co/t/net-core-exception/200485>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [September 20, 2019, 8:05pm UTC](https://discuss.elastic.co/t/net-core-exception/200485 "2019-09-20T20:05:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apm\_user](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apm_user/32/46835_2.png) [@apm\_user](https://discuss.elastic.co/u/apm_user)\
**Post date:** [September 20, 2019, 8:05pm UTC](https://discuss.elastic.co/t/net-core-exception/200485/1 "2019-09-20T20:05:15Z")

</div>

We noticed that the .Net core Agent throws an exception when some headers are repeated. In this specific case Content-Type header with a value "application/json" was specified twice in the request and resulted in an exception. I understand that is is not a valid use case , but it might something to clean up.

{ "time": "2019-09-20 14:18:59.9471", "application\_trace\_id": "0HLPTVNSIHH2O:00000005", "user\_id": "561b95df-3047-47b5-b82d-a4e88c892bd2", "level": "ERROR", "nested": { "message": "Connection id "0HLPTVNSIHH2O", Request id "0HLPTVNSIHH2O:00000005": An unhandled exception was thrown by the application.", "exception": "System.FormatException: The specified content type is invalid.\n at System.Net.Mime.ContentType.ParseValue()\n at System.Net.Mime.ContentType..ctor(String contentType)\n at Elastic.Apm.AspNetCore.ApmMiddleware.FillSampledTransactionContextRequest(HttpContext context, Transaction transaction)\n at Elastic.Apm.AspNetCore.ApmMiddleware.InvokeAsync(HttpContext context)\n at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)" }, "ConnectionId": "0HLPTVNSIHH2O", "TraceIdentifier": "0HLPTVNSIHH2O:00000005", "EventId\_Id": 13, "EventId\_Name": "ApplicationError", "EventId": "ApplicationError" }

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [September 20, 2019, 8:20pm UTC](https://discuss.elastic.co/t/net-core-exception/200485/2 "2019-09-20T20:20:58Z")

</div>

Thanks for reporting this @apm_user

I looked at the code, and I see where the problem is - this should be an easy fix. I opened an issue for it: [https://github.com/elastic/apm-agent-dotnet/issues/502](https://github.com/elastic/apm-agent-dotnet/issues/502) - feel free to watch that for progress.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 11, 2019, 4:22pm UTC](https://discuss.elastic.co/t/net-core-exception/200485/3 "2019-10-11T16:22:34Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
