RaygunClient.Send() fails if two cookies have same name (due to different subdomains)

brunelli

Posted on
May 30 2014

I started getting an error on the call to Send(). It seems to happen when there are 2 cookies with the same name in in Request["cookies"] in ASP.NET. On my site it is possible this happens because cookies may be added under the main domain ".domain.com" and the subdomain ".www.domain.com".

Here is the error:

System.ArgumentException: An item with the same key has already been added.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Mindscape.Raygun4Net.Messages.RaygunRequestMessage.GetCookies(HttpCookieCollection cookieCollection, IEnumerable`1 ignoredFormNames)
   at Mindscape.Raygun4Net.Messages.RaygunRequestMessage..ctor(HttpRequest request, List`1 ignoredFormNames)
   at Mindscape.Raygun4Net.RaygunMessageBuilder.SetHttpDetails(HttpContext context, List`1 ignoredFormNames)
   at Mindscape.Raygun4Net.RaygunClient.BuildMessage(Exception exception, IList`1 tags, IDictionary userCustomData)
   at Mindscape.Raygun4Net.RaygunClient.Send(Exception exception, IList`1 tags, IDictionary userCustomData)

Jamie Penney

Posted on
May 30 2014

Hi,

Thanks for the bug report. This appears to be due to our work splitting the cookies out from the rest of the HTTP headers - I've got an idea how to fix it, but I won't be able to get to it fixed till early next week. It'll require a little bit of work to both the website and the Raygun4net, but it's late on a Friday afternoon and we try not to do a release just before disappearing for the weekend.

My plan is to group the cookies up by domain, instead of just showing a list of them. Then it won't matter if there are overlaps between the domains.

I'll update this thread when the work is done.

Cheers, Jamie


brunelli

Posted on
May 30 2014

Thanks so much for the quick response! I understand about the timing. Let me know if I can help by providing any more information. Have a great weekend.

john


Jamie Penney

Posted on
May 30 2014

No worries John, your stack trace was enough to figure out the problem. Thanks, and have a great weekend yourself (whenever that starts).

Cheers, Jamie


Jamie Penney

Posted on
Jun 04 2014

Hi John,

We've pushed out a new version of the Raygun4NET library to Nuget and an update to the website to support that. If you update to the latest version of Raygun4NET, the problem will disappear. I didn't quite get my way with the cookies (the browser doesn't send back the domain that sent the cookies, I should have remembered that) but I have made sure it lists all the cookies set, even duplicates.

If you have any other issues, please let me know.

Cheers, Jamie


brunelli

Posted on
Jun 06 2014

Great! Updating now. Thanks so much for the quick response.

John


Reply