<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#124; BenHollis.net &#187; ASP.NET</title>
	<atom:link href="http://benhollis.net/blog/tags/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://benhollis.net/blog</link>
	<description>News about BenHollis.net and articles about Ben&#039;s interests</description>
	<lastBuildDate>Fri, 04 Jun 2010 05:39:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Posts I haven&#8217;t written</title>
		<link>http://benhollis.net/blog/2008/10/14/posts-i-havent-written/</link>
		<comments>http://benhollis.net/blog/2008/10/14/posts-i-havent-written/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 07:02:29 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[BenHollis.net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[HAML]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SASS]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/?p=222</guid>
		<description><![CDATA[I haven&#8217;t been updating this blog too much recently. I never meant for this blog to run on a schedule, but I did intend to post more frequently than this. My original idea was that the blog would serve two major purposes. First, it is a place for me to announce new projects or updates [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t been updating this blog too much recently. I never meant for this blog to run on a schedule, but I did intend to post more frequently than this. My original idea was that the blog would serve two major purposes. First, it is a place for me to announce new projects or updates to software and websites I&#8217;ve already released. It&#8217;s done that quite well, though I haven&#8217;t had much to announce recently. My job has been taking the majority of my development time, and most of the projects I&#8217;ve been working on at home are either private or haven&#8217;t been released in the form I&#8217;d like to because my employer hasn&#8217;t approved them for release yet.</p>
<p>The second major purpose for my blog is as a place for me to record the solution to problems I run across while developing software, so that others won&#8217;t have to spend hours Googling or using trial and error to come to the same conclusion. I didn&#8217;t intend to rehash things that were easily found or that had already been discussed &#8211; only to post when I felt it was something that added value to the internet that hadn&#8217;t been there before. So a lot of the blog posts are not really a narrative or running commentary &#8211; they&#8217;re not meant to be subscribed to, but found individually. It&#8217;s for this reason that my most popular posts tend to include the exact text of error messages. This type of post has suffered both because I haven&#8217;t been doing as much development, because I can&#8217;t discuss a lot of what I&#8217;ve learned due to the nature of the projects I&#8217;m working on, and because I&#8217;ve been learning new stuff (like Ruby on Rails) and haven&#8217;t done enough to have solved problems others haven&#8217;t already posted solutions for.</p>
<p>The third reason I have this blog is to occasionally talk about my thoughts on different technical topics, from web development to video games. Again, I don&#8217;t like to make a post unless I think I&#8217;m adding something new, and most of the topics I&#8217;ve wanted to talk about have already been covered. I had a lot of draft posts sitting around about web development, web standards, and the evolution of browsers, but then I discovered <a href="http://alex.dojotoolkit.org/">Alex Russell&#8217;s blog</a> and it turns out he&#8217;s already said most of what I wanted to say, and better than I could. Other stuff, like my impressions of Windows Vista, critique of <a href="http://stackoverflow.com">stackoverflow.com</a> and suggestions for the Xbox Live Arcade lineup, have been covered to my satisfaction in plenty of places. Maybe some of them will end up posted, but probably not.</p>
<p>Another part of the reason I haven&#8217;t posted much is the sheer weight of unfinished posts I have. Right now I have 64 drafts and only 52 real posts! So I&#8217;m going to attempt to clear things out by writing a little about what I haven&#8217;t posted. A lot of this stuff wasn&#8217;t posted because it fell under that third point above, but some of it I was just too lazy to flesh out into real posts. Some of it&#8217;s just random stuff. So here&#8217;s what&#8217;s been happening in the last year:</p>
<p><span id="more-222"></span></p>
<p>I got on the bandwagon and picked up iPhone 3Gs for myself and my wife. Everything good you&#8217;ve heard about the iPhone is true. Also, almost everything bad you&#8217;ve heard about them is true. I really like the device, the UI, and the web browsing, and now that the NDA over the SDK is gone, I might even try to write an app if I get an idea.</p>
<p>I <a href="http://flickr.com/photos/dalangalma/sets/72157594581121699/">built a new computer</a> in March of &#8217;07 to replace the machine I had built for college. The new machine is set up as a developer machine primarily, with the additional goal of being as quiet as possible. I can&#8217;t say I&#8217;m entirely happy with it, since I&#8217;ve had some trouble with the hardware and overheating issues mean I have to run the fans above &#8220;totally silent&#8221; mode. It does its job well enough but I might just buy a Dell next time. The <a href="http://flickr.com/photos/dalangalma/416869374/in/set-72157594581121699/">huge CPU heatsink</a> I used is awesome, though.</p>
<p>I&#8217;ve been running Windows Vista x64 since my new machine came online. While I think it&#8217;s a disappointing release given the 5-year gap between it and Windows XP, I generally like it. It&#8217;s certainly better than Windows XP and I wouldn&#8217;t go back. I&#8217;ve hit some trouble related to using x64, but overall it&#8217;s pleasant.</p>
<p>Before that, I was getting pretty sick of the aging Windows XP, so I bought a Mac Mini and ran it, using OS X 10.4, on a second screen next to my XP machine, joined via <a href="http://synergy2.sourceforge.net/">Synergy</a>. I liked it a lot, but never moved much of my work over there. After getting set up with Windows Vista, the difference between OS X and Windows wasn&#8217;t so great, and I unplugged the Mac so I could have both screens for Windows. I moved the Mini up to my TV and used it with Front Row as a media center. Then the Xbox 360 got the ability to play DivX videos, so I stopped using it for that and brought it back downstairs. I was using it for browser testing, but then Apple released a Windows version of Safari. Now it mostly stays off, except when I want to use Handbrake (which won&#8217;t work on Vista x64). I still like it, and I really miss having an OS with a real command line, especially now that I&#8217;m doing Rails stuff and spelunking through a lot of badly-documented libraries. I&#8217;m not sure I&#8217;ll ever make the switch though. That said, my trusty old Thinkpad finally died last week, and if I can&#8217;t revive it I might look towards the rumored lower-priced MacBooks that should come out soon.</p>
<p>I got <a href="http://flickr.com/photos/genkigecko/sets/72157603357487037/">two awesome cats</a> named Ozette and Skagit. A lot of my time at home just involves relaxing and petting the cats these days.</p>
<p>After years of using Thunderbird, I switched to GMail as my main mail client so I could use it from the web and use IMAP on my iPhone. I set it up to read all my old POP mailboxes, and I use Google Chrome&#8217;s application mode (I used to use <a href="http://labs.mozilla.com/projects/prism/">Mozilla Prism</a>) to make it look like a standalone app on my desktop. It&#8217;s an OK mail reader, especially since I get a lot less email to my personal accounts these days. The main annoyance is spam &#8211; I used to use <a href="http://getpopfile.org/">POPFile</a> to filter spam, and it was perfect, with almost no false positives. In contrast, I get maybe 50 pieces of spam leaking through on GMail a week.</p>
<p>Spam has not been limited to my inbox: my <a href="http://forums.numbera.com">support forums</a> are basically nothing but spam and people complaining about stuff I&#8217;ve given them for free. It takes a lot of maintenance, and I&#8217;m thinking of either trying to transition them to something less attractive to spammers, or just shutting them down entirely.</p>
<p>Back when IE7 was in beta I wrote a handful of bug repro&#8217;s for problems I found with it. Recently I&#8217;ve been running across all kinds of crazy things in both Firefox and IE, so I&#8217;ve been <a href="http://brh.numbera.com/experiments/browserdemos/">cataloguing them</a> with little examples. Most of them have been fixed with the latest release of each browser, but I figure they&#8217;re still useful if anybody&#8217;s seeing those problems happen.</p>
<p>I went to <a href="http://flickr.com/photos/genkigecko/sets/72157606388198812/">Southeast Asia</a> for two and a half weeks. We toured Vietnam, Cambodia and Thailand. It was incredible.</p>
<p>I finally got so sick of CSS that I decided to write a processor that would take an &#8220;evolved&#8221; CSS syntax that supported named constants, nested selectors, arithmetic, mixins, and such and spit out real CSS. I had it all sketched out and was ready to start implementing when I found <a href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html">SASS</a>, from the same guy who awesome-ified HTML with <a href="http://haml.hamptoncatlin.com/">HAML</a>. SASS is feature-by-feature the exact same thing I wanted to do (except for the whitespace-significant thing, but I can deal). I love it.</p>
<p>I&#8217;ve been pretty disillusioned with ASP.NET as a web platform &#8211; the web forms are too inflexible and unfriendly to clean markup and unobtrusive JavaScript, and C# feels too rigid and verbose for what I&#8217;m doing. LINQ and the other 3.5 features help a lot, but my host is stuck on 2.0. I still haven&#8217;t found any templating system that trumps Web Forms, which is why I&#8217;m still stuck on Windows hosting for the most part &#8211; a lot of my sites are built on ASP.NET for nothing more than the templating. While I&#8217;m keeping my eye on ASP.NET MVC, I&#8217;m more interested in cross-platform web technologies that give me a bit more choice in hosting.</p>
<p>To that effect, I&#8217;ve started a personal project on Ruby on Rails, mostly to learn the platform. So far I&#8217;ve really been liking it &#8211; having a functional, dynamic language is great, and the structure Rails gives you really helps to quickly get things running. Hopefully I&#8217;ll be able to show what I&#8217;m making at some point, assuming it works to my satisfaction.</p>
<p>I actually went through a big comparison of different web platforms and different languages, trying to gauge what would be the best for me to develop for. I&#8217;m not sure I&#8217;ll ever publish my full results, but Ruby on Rails was obviously up there, and Django / Python looked good too. </p>
<p>Speaking of languages, before I discovered <a href="http://jquery.com">jQuery</a> I didn&#8217;t really do much JavaScript if I could avoid it. Now I&#8217;m writing tons of JavaScript to produce some really nice interactive web apps. I have never been as impressed with a library or platform as I have been with jQuery.</p>
<p>I&#8217;ve actually been using Eclipse a lot lately, both for Aptana and for straight Java development, and while it&#8217;s slower and buggier than Visual Studio, a free copy of Eclipse plus all the free plugins make it much more compelling than the Visual Studio Express products I use for C# work. Stuff like the outline view, refactoring support, quick fix mode, and real unit testing and source control plugins make all the difference.</p>
<p>I think that&#8217;s about all I wanted to get off my chest for now. Hopefully I&#8217;ll have a chance to flesh some of that out into full posts sometime, but at least I won&#8217;t have so many unwritten drafts staring at me every time I log in to WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2008/10/14/posts-i-havent-written/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using MyODBC with ASP.NET in IIS7 on Vista x64</title>
		<link>http://benhollis.net/blog/2007/03/27/using-myodbc-with-aspnet-in-iis7-on-vista-x64/</link>
		<comments>http://benhollis.net/blog/2007/03/27/using-myodbc-with-aspnet-in-iis7-on-vista-x64/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 08:07:27 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[MyODBC]]></category>
		<category><![CDATA[Windows Vista x64]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2007/03/27/using-myodbc-with-aspnet-in-iis7-on-vista-x64/</guid>
		<description><![CDATA[That&#8217;s a heck of a title, but it&#8217;s a problem I hit recently. I have a bunch of ASP.NET sites that use MySQL as their datastore, but I hadn&#8217;t tried the on IIS7 yet. It took a while to get them to work at all (I had to set permissions on web.config and the other [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s a heck of a title, but it&#8217;s a problem I hit recently. I have a bunch of ASP.NET sites that use MySQL as their datastore, but I hadn&#8217;t tried the on IIS7 yet. It took a while to get them to work at all (I had to set permissions on web.config and the other website files so that they could be read by both the Users group and the IIS_IUSRS group), but then I was left with an error about my MySQL connection. &#8220;<kbd>ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified</kbd>&#8221; &#8211; another very general error that basically means &#8220;Something is wrong with your ODBC driver, somewhere.&#8221;</p>
<p>After some searching, I learned two things. The first is that if you&#8217;re running 64-bit you can&#8217;t use the standard ODBC Data Source Administrator in Administrative Tools with MySQL. You&#8217;ve got to go to C:\Windows\SysWOW64\odbcad32.exe and set up your DSN, if that&#8217;s your thing. The other thing is that the MyODBC driver is <strong>32-bit only</strong>. So to use it at all, you need to make sure you&#8217;re calling it from 32-bit apps only. That means you&#8217;ve got to tweak the Application Pool you&#8217;re using to run all its ASP.NET applications as 32-bit. To do this, go to Administrative Tools > Internet Information Services (IIS) Manager (or just hit the Windows key and type &#8220;IIS&#8221;). Then go to &#8220;Application Pools&#8221; and select whichever application pool your ASP.NET app uses (or create a new one just for your MySQL apps. Click &#8220;Advanced Settings&#8230;&#8221; and set &#8220;Enable 32-Bit Applications&#8221;. Now the AppPool will use the 32-bit .NET CLR to run your app, and it&#8217;ll be able to see your MyODBC driver (whether you use a DSN or not).</p>
<p style="text-align:center"><img src='http://brh.numbera.com/blog/wp-content/uploads/2007/03/iis32bit.png' alt='IIS7 32-bit Application Pool' /></p>
 <div class="postAdsense">
<script type="text/javascript"><!--
google_ad_client = "pub-0806135767465122";
/* BRH Blog Post */
google_ad_slot = "2708897180";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2007/03/27/using-myodbc-with-aspnet-in-iis7-on-vista-x64/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Creating nested custom configuration sections in ASP.NET 2.0</title>
		<link>http://benhollis.net/blog/2006/10/02/creating-nested-custom-configuration-sections-in-aspnet-20/</link>
		<comments>http://benhollis.net/blog/2006/10/02/creating-nested-custom-configuration-sections-in-aspnet-20/#comments</comments>
		<pubDate>Mon, 02 Oct 2006 20:29:36 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Configuration]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2006/10/02/creating-nested-custom-configuration-sections-in-aspnet-20/</guid>
		<description><![CDATA[This weekend I decided to go through the hodgepodge of common code that's shared between a lot of my ASP.NET websites and refactor it a bit. I'd only just learned about the magic of HttpModules and HttpHandlers, and I immediately saw a lot of canidates in my copy-paste code and global.asax handlers where a HttpModule [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I decided to go through the hodgepodge of common code that's shared between a lot of my ASP.NET websites and refactor it a bit. I'd only just learned about the magic of <a href="http://www.15seconds.com/issue/020417.htm">HttpModules and HttpHandlers</a>, and I immediately saw a lot of canidates in my copy-paste code and global.asax handlers where a HttpModule would be a better solution. One of these was the code I was using to redirect old pages to new pages whenever I moved them. For example, at some point I had moved <a href="http://www.numbera.com/rome/tools.aspx">http://www.numbera.com/rome/tools.aspx</a> to <a href="http://www.numbera.com/rome/tools/">http://www.numbera.com/rome/tools/</a>, and I wanted anyone who visited the old URL to get redirected to the new one. Previously, I just had some code in global.asax that hooked Application_OnError, checked to see if it was an HttpException (a 404 file not found, specifically), and then redirected if it knew where the file really was. Pretty simple, but not very general. So I broke it out into an HttpModule that basically did the same thing, but no longer required me to cut and paste code into my global.asax. However, one improvement I wanted to make was to allow for configuration through my web.config file, instead of having to hardcode an if/else tree for each redirect. I basically wanted to have a section in my web.config like this:</p>
<div class="igBar"><span id="lxml-4"><a href="#" onclick="javascript:showPlainTxt('xml-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-4">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configSections<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sectionGroup</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"brh.web"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;section</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">"redirectOldUrls"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">type</span>=<span style="color: #ff0000;">"Brh.Web.RedirectConfigurationHandler, Brh.Web.Utility"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sectionGroup<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configSections<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;brh</span>.web<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirectOldUrls<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirect</span> <span style="color: #000066;">filePattern</span>=<span style="color: #ff0000;">"tools.aspx"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"~/tools/"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirect</span> <span style="color: #000066;">filePattern</span>=<span style="color: #ff0000;">"strategy.aspx"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"~/strategy/"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirect</span> <span style="color: #000066;">filePattern</span>=<span style="color: #ff0000;">"military_people.aspx"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"~/people/"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirect</span> <span style="color: #000066;">filePattern</span>=<span style="color: #ff0000;">"history.aspx"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"~/history/"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;redirect</span> <span style="color: #000066;">filePattern</span>=<span style="color: #ff0000;">"teacher.aspx"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"~/teacher/"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/redirectOldUrls<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/brh</span>.web<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><span id="more-22"></span></p>
<p>To do this, I needed to create a custom configuration handler. There's plenty of documentation out there on how to create a single-tag configuration handler using the new ConfigurationSectionHandler class, and all of the sites I could find talked about how much easier it was to do things the new .NET 2.0 way instead of using IConfigurationSectionHandler. However, nothing I could find would tell me how to make a config section with sub-elements. It's certainly easy to decorate a property with the ConfigurationProperty attribute, but setting up the collection of subelements is significantly harder. Finally, after chancing upon <a href="http://forums.asp.net/thread/1380269.aspx">a forum post</a>, I was able to hack together something that worked:</p>
<div class="igBar"><span id="lcsharp-5"><a href="#" onclick="javascript:showPlainTxt('csharp-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-5">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Configuration</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">namespace</span> Brh.<span style="color: #0000FF;">Web</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">class</span> RedirectConfigurationHandler : ConfigurationSection</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>ConfigurationProperty<span style="color: #000000;">&#40;</span><span style="color: #808080;">""</span>, IsDefaultCollection=<span style="color: #0600FF;">true</span>, IsKey=<span style="color: #0600FF;">false</span>, IsRequired=<span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> RedirectCollection Redirects</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">""</span><span style="color: #000000;">&#93;</span> <span style="color: #0600FF;">as</span> RedirectCollection;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">""</span><span style="color: #000000;">&#93;</span> = value;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">class</span> RedirectCollection : ConfigurationElementCollection</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> ConfigurationElement CreateNewElement<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> RedirectElement<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">object</span> GetElementKey<span style="color: #000000;">&#40;</span>ConfigurationElement element<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>RedirectElement<span style="color: #000000;">&#41;</span>element<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">FilePattern</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span> ElementName</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #808080;">"redirect"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">bool</span> IsElementName<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> elementName<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> !<span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>elementName<span style="color: #000000;">&#41;</span> &amp;&amp; elementName == <span style="color: #808080;">"redirect"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> ConfigurationElementCollectionType CollectionType</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> ConfigurationElementCollectionType.<span style="color: #0000FF;">BasicMap</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> RedirectElement <span style="color: #0600FF;">this</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">int</span> index<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">BaseGet</span><span style="color: #000000;">&#40;</span>index<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">as</span> RedirectElement;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">class</span> RedirectElement : ConfigurationElement</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>ConfigurationProperty<span style="color: #000000;">&#40;</span><span style="color: #808080;">"filePattern"</span>, IsRequired=<span style="color: #0600FF;">true</span>, IsKey=<span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> FilePattern</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"filePattern"</span><span style="color: #000000;">&#93;</span> <span style="color: #0600FF;">as</span> <span style="color: #FF0000;">string</span>; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"filePattern"</span><span style="color: #000000;">&#93;</span> = value; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>ConfigurationProperty<span style="color: #000000;">&#40;</span><span style="color: #808080;">"url"</span>, IsRequired=<span style="color: #0600FF;">true</span>, IsKey=<span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> RedirectUrl</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"url"</span><span style="color: #000000;">&#93;</span> <span style="color: #0600FF;">as</span> <span style="color: #FF0000;">string</span>; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"url"</span><span style="color: #000000;">&#93;</span> = value; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The important parts here are that I overrode the CollectionType on RedirectCollection, which allows me to use a simple mapping instead of the more complex add/remove/clear pattern that the new Configuration API selects by default. Also, I overrode the parts about the element name, so that it would recognize a series of "redirect" tags as my collection. The last bit that hung me up for a long time was that my ConfigurationElement, RedirectElement, needs to store its data in the base property collection. I had been storing them as properties, thinking that the configuration framework would populate them via reflection, but all that got me was a "Invalid key value" error, since the collection was exposing RedirectElement.FilePattern as the "key" (whatever that means) and it was null. I still don't really understand all the craziness about this new configuration system, but at least I got it working. I wish there was better documentation out there (or at least better error messages). In general I think this is way too complex a way to go about handling configuration - I'll stick with simply serializing/unserializing a custom settings object in my Windows apps.</p>
<p>One last bit: to use this in your app, simply do this:</p>
<div class="igBar"><span id="lcsharp-6"><a href="#" onclick="javascript:showPlainTxt('csharp-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-6">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RedirectConfigurationHandler config = <span style="color: #000000;">&#40;</span>RedirectConfigurationHandler<span style="color: #000000;">&#41;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">Configuration</span>.<span style="color: #0000FF;">ConfigurationManager</span>.<span style="color: #0000FF;">GetSection</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"brh.web/redirectOldUrls"</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now you have a strongly typed config object that you can use to read your settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2006/10/02/creating-nested-custom-configuration-sections-in-aspnet-20/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
