[Widget][AlphaTags] Given key not present in the dictionary

Topics: Controls
Dec 11, 2011 at 2:35 PM

Hello All,

I am getting alot of these errors:

--------------------------------------------------------------------------------------
The given key was not present in the dictionary.

Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

Source Error:

Line 184:                    else
Line 185:                    {
Line 186:                        tagLists.AppendFormat(tagLI, Utils.RelativeWebRoot, HttpUtility.UrlEncode(key), key, this.WeightedList[key]);
Line 187:                    }
Line 188:                }


Source File: c:\wwwroot\App_Code\Controls\AlphaTags.cs    Line: 186

--------------------------------------------------------------------------------------

Noticing that the bots are the main ones that are triggering it.

But, it happen to me too through once. 

Just installed the widget yesterday, good widget but just getting these errors.

 

Have a good day,

Brian Davis

 

 

Dec 11, 2011 at 4:59 PM

Hi Brian,

Good to get feedback.

I'm intrigued as to what's happening here, been running this for quite some time live on BE 2 with a tag count of around 200 and tested locally on a number of different themes, but nothing beats real world testing.

What kind of set-up do you have, this would be helpful, so that I can try and reproduce the errors and get it sorted.

I noticed in a previous post that you discovered problems with the CategoryList.cs, triggered by the bots, is this happening with the standard BE control or the nested categories control? 

Cheers

 

Dec 11, 2011 at 6:23 PM

I only seen the error myself 1 time.

But, I know of the errors because I was looking at my ELMAH Log

ScreenShot: ELMAH Log

ScreenShot: Individual Error Log

ScreenShot: Original ASP.NET error page 

Also I have my server set up to send me an email anytime that the server is down.

It was just luck or odd chance that I personally saw the error myself.

So others might be getting this error and just don't know about it.

------------------------------------

I am using: BlogEngine.NET 2.5.0.15

My Server Setup:

SERVER_SOFTWARE: Microsoft-IIS/7.0

XML as Database

ASP.Net 4.0 With Integrated App_Pool

Live Site is at: http://programmingsolution.net/

---------------------------------------------

I noticed in a previous post that you discovered problems with the CategoryList.cs, triggered by the bots, is this happening with the standard BE control or the nested categories control?

I am using the Standard BE controls, CategoryList.cs

I compared it with the latest BE source code.

BE 2.5.0.22

When compared using the plugin NotePad++ it said it was a match.

So having different version is not an issue its the same as everyone else.

-------------------------------------------------

I gave you everything I can think of so you can try to figure this out :)

It got me puzzled because I am trying to recreate the error but it won't do it.

But, I still see the error occurring in the Error Log through.

I am refreshing the website every 5 mins for about 2 hours so far no error spoted for me,

but in Error log still showing up through.

------------------------------------------------

Well, good luck figuring this one out :)

Any body else that has this widget Alpha Tags install please check your error logs

like the logger or if you have Elmah log installed check that too.

Or your Server log files look for Error 500

--------------------------------------------------

Let me know if you figure this out.

 

Thanks,

 

Brian Davis

 

Dec 12, 2011 at 2:23 PM

Hi Brian,

I loaded Elmah on BE 2 live and 2.5 build 21 and 22 locally and have been unable to log any errors with the tag widget.

You can check it on the live site if you want (I'll leave Elmah in place for a day or two before removing it).

I did get quite a number of other errors on the live site, like this for example.

CORVETTE 404 Http The file '/post/2011/08/14/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx' does not exist. Details…

However, the file does exist and is accessible, and it's a similar story with all the other errors, so I'm not sure what's going on with the error logging.

Clearly errors were being logged on your site, I did have a play around with the widget when you had it installed at http://programmingsolution.net/ but couldn't induce any errors on the front end.

I've now wrapped the code that was causing logging errors with a TryGetValue, which shouldn't do any harm but might just stop the log errors.

if (this.WeightedList.TryGetValue(key, out tagCount))
                    {
                        if (key == queryTag)
                        {
                            tagLists.AppendFormat(tagLISelected, key, this.WeightedList[key]);
                        }
                        else
                        {
                            tagLists.AppendFormat(tagLI, Utils.RelativeWebRoot, HttpUtility.UrlEncode(key), key, this.WeightedList[key]);
                        }
                    }
I'll upload the updated package to the gallery later today.

 

Dec 12, 2011 at 3:56 PM

Hello Andy,

Thanks for your help on this so far :)

I forgot to mention, I am using multiple widget zones.

Thats the only difference there is between what I have and what you had tested so far.

I have widget zones for the following:

default page (Home Page)

Post

Pages

Non-Standard pages (Contact,Archive, and etc)

I did had the Alpha Tag widget on the

Default and Post Widget Zones.

But I deleted the one on the default widget zone and have it now only on the Post widget zone.

Hoping that was the issue just having more than 1 widget on the same site.

But, still getting the same error.

So it appears that its not the multiple widget zones thats causing the problem.

The Alpha Widget is now only on the post pages like this one:

 

http://programmingsolution.net/post/Comma-Separated-List-CSV-of-rows-of-a-column-using-FOR-XML-PATH.aspx

 

Which is one of the posts that were giving the error.

 

Seems like its a URL path issue.

Noticing it is being caused the most when

1. Bots visit

2. When a user visit from a search engine using a search  query.

 

All so all errors are using Permalink links:

post.aspx
QUERY_STRING id=0c5bf696-1f65-4b69-b198-fdbd347c3971

 

When using the re written URL like

http://programmingsolution.net/post/Comma-Separated-List-CSV-of-rows-of-a-column-using-FOR-XML-PATH.aspx

Gives no error.

But when it uses the Permalink for that URL it does.

But, again I am only seeing this through the log files and not actually seeing it myself through.

 

--------------------------------

I see I am not the only one getting the other errors too :)

 

See you are also getting the PostPager error.

 

The pages not found errors are telling the truth :) They are right

You just got to look at your URL very closely.

Look at this one:


post/2011/08/14/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx   <--- Does not exist

post/2011/08/06/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx     <-- This is the correct one

 

Its off by the day of the week.

So this is when ELMAH and the SEO Redirector comes to the rescue!!!

 

Again heres another:

 

http://www.mobiletvworld.com/post/2011/04/23/Apple-Reports-83-Growth-in-Revenue.aspx    <--- Does not work

Couldn't find this post any where on your website.

Heres a screenshot of the Archive listing for the Month of April 2011

There is no post with the date [2011/04/23] listed in the url above.

Point being ELMAH doesn't lie :) 

Its telling you the truth those URL's does not exist "as they are" on your website.

Also doing a Google search for "Apple-Reports-83-Growth-in-Revenue.aspx"

also shows that Google has crawled it as "Page Not Found".

So now you know for sure that ELMAH is right :)

--------------------------------------------------------

An other thought as we are on the subject and have been meaning to mention this before.

Why not have the Page Not Found  return

a Search results

Based on the URL thats 404 with the "-" dashes taken out.

For Example:

post/2011/08/14/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx

It will search for:

"Mobile Digital Television on Track to Reach Two-Thirds of U.S. Households by Early Next Year"

Return this page: Search Results

Instead of the standard

Ooops! I can't find the page you're looking for

You might find one of the following links useful:

Maybe have the search results displayed under the text

"You Might fine one of the following links useful:"

 

Which currently only displays:

 

And a Search box.

 

Maybe have the Search box prefilled with the URL with the 404?

Then user just press search?

--------------------------------------

Just wanted to get that one off my chest been wanting to say that for a long time :)

 

 

Have a good day,

 

Brian Davis

Dec 12, 2011 at 5:20 PM

Hi Brian,

As you already spotted, the widget should be fine in multiple widget zones as long as only one is visible at a time.

It looks good on your site and it would be nice to get to the bottom of what's causing the problems.

What you say about it being a URL path issue makes allot of sense, I've sent you an updated version via the contact form on programmingsolutions.net.

This version doesn't address the URL issue, but I'm hoping it can ignore it (can't be sure since I've not had the errors yet to test against).

Just as a matter of interest - do you get similar errors with the standard TagCloud.s in place?

The AlphaTags control is adapted from the TagCloud.cs and the URL coding for this I think is the same.

Well spotted on this:

post/2011/08/14/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx   <--- Does not exist

post/2011/08/06/Mobile-Digital-Television-on-Track-to-Reach-Two-Thirds-of-US-Households-by-Early-Next-Year.aspx     <-- This is the correct one

The other posts/pages have been deleted, your'e right - ELMAH doesn't lie :) .

An excellent suggestion for the pages not found - that's going on the to do list (don't suppose you have cut and paste code for that handy :) )

 

 

 

Dec 13, 2011 at 6:12 AM

Just as a matter of interest - do you get similar errors with the standard TagCloud.s in place?

No didn't get any errors from the standard TagCloud

Just uploaded the code you gave me.

Will see if I still get errors, will keep you posted.


Hope it works :)

Thanks,

Brian Davis

Dec 13, 2011 at 11:10 AM

as of 6:10 am no errors so far :)

Dec 13, 2011 at 12:21 PM

Breathes a heavy sigh of relief.

That was useful knowing that TagCloud.cs gave no errors, I've checked through the code again and spotted what I think was causing the problem in the first place.

I'll make the changes and if you don't mind me passing on the code it would be great if you could check it out - much appreciated.

 

 

Dec 13, 2011 at 12:51 PM

So far 7:44 am no errors :)

 

I will test your code :) 

 

Just give me the code :)

 

Again thanks a million!!!

 

The Alpha Tag widget is very useful when you have 100's of Tags.

--------------------------------------------------------------------------------

I also been meaning to ask you about your widgets on your site:

Screen Shot

Where did you get it? 

I see some WordPress themes have it but didn't see any BlogEngine Themes that haves it.

Did you write it yourself?

If you don't mind I would like to have it :) Both of them thats in the screen shot.

or better yet release it to the gallery :)

 

Well worth a shot to ask :)

It would help a lot with my site since it has lots of widgets this will

free up some space and hopefully load time too.

------------------------------------------------------------------------------------------------

You can email me directly at:

Kbdavis07@yahoo.com

 

Thanks,

Brian Davis

Dec 13, 2011 at 1:12 PM

Cheers Brian,

Your'e welcome to whatever you think might be useful.

All this stuff was done for BE 2 and may need some working for BE 2.5 depending on how you use it.

The tabbed panels are just tabbed panels with controls inside and a little jiggery pokery to get them to behave.

I'll send the amended AlphaTags first via your direct email. 

Dec 13, 2011 at 4:39 PM

Thanks!!!

Looking forward for the email :)