Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Key/Value List

Tags:

asp.net

c#-3.0

I'm doing a custom 404 page for a large website that's undergoing a redesign. There are about 40 high-use pages that customers may have bookmarked, and our new site structure will break these bookmarks.

On my custom 404 page, I want to alert them to the new URL if they attempt to navigate to one of these high-use pages via its old URL. So I have a couple of dynamic controls on the 404 page, one for a "did-you-want-this?" type of dialog, and another for a "if-so-go-here (and update your bookmark)" type of dialog. That's the easy part.

To suggest a new URL, I'm looking at the requested URL. If it has key words in it, I'm going to suggest the new URL based on that, and them I'm firing off the appropriate did-you-want..., and if-so... suggestions on the 404 page as mentioned above.

So I want to store these 40-ish key/value pairs (keyword/new-URL pairs) in a data structure, and I'm not sure what would be best. Dictionary? IDictionary? What's the difference and which is more appropriate?

Or am I totally on the wrong track?

Thanks for your time.

like image 804
theog Avatar asked Jun 25 '26 17:06

theog


2 Answers

I would use the Dictionary<T,T> from the System.Collections.Generic namespace.

like image 151
tvanfosson Avatar answered Jun 28 '26 07:06

tvanfosson


You could use NameValueCollection.

like image 20
Craig Avatar answered Jun 28 '26 07:06

Craig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!