<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.Net</title>
        <link>http://sean-lynch.net/category/3.aspx</link>
        <description>.Net</description>
        <language>en-US</language>
        <copyright>Sean Lynch</copyright>
        <managingEditor>slynch13@gmail.com</managingEditor>
        <generator>Subtext Version 2.0.0.9</generator>
        <item>
            <title>ScriptControl question</title>
            <link>http://sean-lynch.net/archive/2008/07/07/scriptcontrol-question.aspx</link>
            <description>&lt;p&gt;As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file.&lt;/p&gt;  &lt;p&gt;I have to say I really like the extender and script controls that come with the ASP.NET AJAX. They really are so much nicer to work with then building up Javascript strings in the CS file of the server control. &lt;/p&gt;  &lt;p&gt;I do have a question about them though. One of the ScriptControls I made uses a webservice to pull data if the service name is set. At the moment I have it dynamically registering an JSON script service based webservice. Unfortunately I have found that this is not an optimal solution since the name of the Javascript object created by the ScriptService changes depending on the namespace and class name of the service. &lt;/p&gt;  &lt;p&gt;I am sure that there is a better way to do this, but I am not exactly certain of it. Any suggestions or links would be appreciated.&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/57.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2008/07/07/scriptcontrol-question.aspx</guid>
            <pubDate>Tue, 08 Jul 2008 04:09:08 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/57.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2008/07/07/scriptcontrol-question.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/57.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/57.aspx</trackback:ping>
        </item>
        <item>
            <title>Lazy list</title>
            <link>http://sean-lynch.net/archive/2008/05/21/lazy-list.aspx</link>
            <description>&lt;p&gt;I have been following &lt;a href="http://blog.wekeroad.com/" target="_blank"&gt;Rob Conery's&lt;/a&gt; posts on the MVC Storefront, and trying the repository/pipes-filters for data access that he has been using.&lt;/p&gt; &lt;p&gt;While trying out the implementation of a LazyList he was using, I had noticed that the example table was being joined onto the category table. At the time however, I really had not thought much of it, until I read &lt;a href="http://blog.wekeroad.com/mvc-storefront/mvcstore-intermission2/" target="_blank"&gt;MVC Storefront: Brainbender Intermission&lt;/a&gt; which got me thinking. &lt;/p&gt; &lt;p&gt;Admittedly, I don't really have to much of a problem with it loading all of the examples for all the categories at one time at the moment. However, I figured it would be nice to have it work the way intended, and query the database for the examples in a category only when asked for.&lt;/p&gt; &lt;p&gt;I liked the idea of the LazyList, and since I was already using a Service class for all data access, along with setting up the category hierarchy I moved the creation of the LazyList of examples property into the the GetCategories method of the service class.&lt;/p&gt; &lt;p&gt;It seems that as long as the LazyList is created after the categories .ToList() call it properly works. So I ended up with this code:&lt;/p&gt;&lt;pre class="code"&gt;            categories.ForEach(category =&amp;gt;
            {
                category.Examples =
                    &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;LazyList
&lt;/span&gt;                        &amp;lt;DevExamples.Data.&lt;span style="color: rgb(43,145,175)"&gt;Example&lt;/span&gt;&amp;gt;(
                        &lt;span style="color: rgb(0,0,255)"&gt;from&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; repository.GetExamples()
                        &lt;span style="color: rgb(0,0,255)"&gt;where&lt;/span&gt; e.CategoryId == category.ID
                        &lt;span style="color: rgb(0,0,255)"&gt;select&lt;/span&gt; e);

                &lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; subCategories = (&lt;span style="color: rgb(0,0,255)"&gt;from&lt;/span&gt; sub &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; categories
                                     &lt;span style="color: rgb(0,0,255)"&gt;where&lt;/span&gt; sub.ParentId == category.ID
                                     &lt;span style="color: rgb(0,0,255)"&gt;select&lt;/span&gt; sub).ToList();
                category.SubCategories = subCategories;

                subCategories.ForEach(c =&amp;gt; c.Parent = category);

            });
&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b2911609-4a75-4f29-a40f-6f2131b013b6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/aspnetmvc" rel="tag"&gt;aspnetmvc&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/56.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2008/05/21/lazy-list.aspx</guid>
            <pubDate>Wed, 21 May 2008 12:34:18 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/56.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2008/05/21/lazy-list.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/56.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/56.aspx</trackback:ping>
        </item>
        <item>
            <title>ABCs scare me</title>
            <link>http://sean-lynch.net/archive/2008/02/22/abcs-scare-me.aspx</link>
            <description>&lt;p&gt;I had a whole post about this, in my mind, but as I was typing, I kept poking holes in my points as to why I hope that in the end IHttpContext stays around. &lt;/p&gt;
&lt;p&gt;However, since am trying get into the habit of actually sleeping at night I'm just going to put a couple of sentences in. &lt;/p&gt;
&lt;p&gt;In &lt;a target="_blank" href="http://haacked.com/archive/2008/02/21/abstract-base-classes-have-versioning-problems-too.aspx"&gt;Abstract Base Classes Have Versioning Problems Too&lt;/a&gt; Haacked gave an example that of a problem with ABCs, that at some point later a virtual method would be added, and throw a not implemented exception. This in itself seems to be a breaking change to me, its just a matter of where it breaks. &lt;/p&gt;
&lt;p&gt;Now instead of stopping my program from working if an ISV's customer decides to run it on the new framework. It will fail in some completely unexpected way, causing extra support calls, and possibly causing sever side effects. &lt;/p&gt;
&lt;p&gt;So while I am all for putting the ball in the developers court, putting the ball in my customers court scares the crap out of me. And that is essentially what I see using an abstract base classes to allow for extensibility and then adding virtual methods, since they cannot be actual abstract methods or we are in the same boat as interfaces, that throw not implemented exceptions does. &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1b203989-87d8-4489-b30b-12e6bb1c3473" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/Microsoft%20MVC"&gt;Microsoft MVC&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/51.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2008/02/22/abcs-scare-me.aspx</guid>
            <pubDate>Fri, 22 Feb 2008 17:29:07 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/51.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2008/02/22/abcs-scare-me.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/51.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/51.aspx</trackback:ping>
        </item>
        <item>
            <title>I think I'm missing something</title>
            <link>http://sean-lynch.net/archive/2008/02/05/i-think-im-missing-something.aspx</link>
            <description>&lt;p&gt;I finally found time to work on &lt;a title="DevExamples" href="http://www.devexamples.com"&gt;DevExamples.com&lt;/a&gt; again and thought I would check on the suggestion that Richard had left on &lt;a href="http://myheadsexploding.com/archive/2007/12/24/got-my-nice-urls-working.aspx"&gt;Got my nice Urls working&lt;/a&gt; about using incremental LINQ.&lt;/p&gt; &lt;p&gt;Overall I found that I liked the following syntax much better&lt;/p&gt;&lt;pre class="code"&gt; &lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; cats = &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;.Categories.Where(c =&amp;gt; c.Name == navList.First().Value);
 &lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; item &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; navList.Skip(1))
 {
  &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; name = item.Value;
  cats = cats.Where(c =&amp;gt; c.Name == name);
 } 
 cat = cats.First();
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Unfortunately this only works for the first parent in the hierarchy. After the first parent, it continues to simply work off of the single join. The problem is that instead of generating &lt;/p&gt;
&lt;p&gt;&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_18.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="100" alt="image" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_thumb_8.png" width="515" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;&lt;p&gt;it is generating 
&lt;/p&gt;&lt;p&gt;&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_14.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="75" alt="image" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_thumb_6.png" width="516" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;&lt;p&gt;I think I understand why I am getting this result, though it was not what I was hoping. 
&lt;/p&gt;&lt;p&gt;In the end I think I will stick with how I implemented it in &lt;a href="http://myheadsexploding.com/archive/2007/12/24/got-my-nice-urls-working.aspx"&gt;Got my nice Urls working&lt;/a&gt; until I either think of, or run into, a way to do it with lambda expression. Plus I like the Sql  generated in the previous post a little better mostly for trace readability.
&lt;/p&gt;&lt;p&gt;&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="130" alt="image" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/IthinkImmissingsomething_13C96/image_thumb_5.png" width="503" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:eb70ad59-4cf9-44df-ad45-3ba062673b41" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/LINQ%20to%20SQL" rel="tag"&gt;LINQ to SQL&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/48.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2008/02/05/i-think-im-missing-something.aspx</guid>
            <pubDate>Wed, 06 Feb 2008 10:30:57 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/48.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2008/02/05/i-think-im-missing-something.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/48.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/48.aspx</trackback:ping>
        </item>
        <item>
            <title>Got my nice Urls working</title>
            <link>http://sean-lynch.net/archive/2007/12/24/got-my-nice-urls-working.aspx</link>
            <description>&lt;p&gt;Its amazing how fast things can be done when not fighting bad assumptions. In this case it was that my admin URLs needed to use the nice descriptive URLs, instead of just /[Controller]/[Action]/[id] type routing.&lt;/p&gt; &lt;p&gt;Once I realized I was making things overly complicated I, I ended up with a set of routing functions that are actually a bit less complicated then what I would have come up with if I had been able to extend the RouteTable the way I had planned originally.&lt;/p&gt; &lt;p&gt;I also decided that I didn't like the idea of having the make every category and example name unique. Most of this was that I'm not the creative, but I also realized that it would be really ugly I wanted to have namespaces as categories. For example, it would not have been possible to have both C/System/Windows/Forms/Control and C/System/Web/UI/Control since Control would have had to be unique.&lt;/p&gt; &lt;p&gt;I also decided that I was going to set a limit to the depth of categories that the site was going to have, though it is easy to update this. First I made a function that would generate routes similar to those &lt;a href="http://myheadsexploding.com/archive/2007/12/13/routing-revisited.aspx"&gt;previously posted&lt;/a&gt;. &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; CreateRouteSet(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; baseRoute, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; baseName
    , &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; maxDepth, &lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt; Defaults)
{
    &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt; sb = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt;();
    &lt;span style="color: rgb(0,0,255)"&gt;for&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; i = 0; i &amp;lt; maxDepth; i++)
    {
        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (sb.Length &amp;gt; 0)
            sb.Append(&lt;span style="color: rgb(163,21,21)"&gt;"/"&lt;/span&gt;);

        sb.AppendFormat(&lt;span style="color: rgb(163,21,21)"&gt;"[{0}{1}]"&lt;/span&gt;, baseName, i);

        &lt;span style="color: rgb(43,145,175)"&gt;RouteTable&lt;/span&gt;.Routes.Add(&lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Route&lt;/span&gt;{
         
            Url = &lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;.Format(baseRoute,sb.ToString()),
            Defaults = Defaults,
            RouteHandler = &lt;span style="color: rgb(0,0,255)"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43,145,175)"&gt;MvcRouteHandler&lt;/span&gt;)
        });
    }
}

&lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; Application_Start(&lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43,145,175)"&gt;EventArgs&lt;/span&gt; e)
{

    CreateRouteSet(&lt;span style="color: rgb(163,21,21)"&gt;"C/{0}"&lt;/span&gt;, &lt;span style="color: rgb(163,21,21)"&gt;"Category"&lt;/span&gt;, 6,
        &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; { Action = &lt;span style="color: rgb(163,21,21)"&gt;"Index"&lt;/span&gt;, Controller = &lt;span style="color: rgb(163,21,21)"&gt;"Categories"&lt;/span&gt; }
        );

    &lt;span style="color: rgb(0,128,0)"&gt;//Other routes using the standard [Controller]/[Action]/[Id]&lt;/span&gt;

}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;This will setup routes to handle category hierarchies up to 6 deep.  And add Category1,Category2... into the RouteData.Values collection in the controller.&lt;/p&gt;
&lt;p&gt;Next I set up the code to allow me to handle the route, which I did in the model, adding a method that takes an IDictionary&amp;lt;string,object&amp;gt;. &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Category&lt;/span&gt; GetCategoryFromRouteData(&lt;span style="color: rgb(43,145,175)"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;,&lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt;&amp;gt; data)
{
&lt;span style="color: rgb(0,128,0)"&gt;    //Grab just the category data&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; navList = &lt;span style="color: rgb(0,0,255)"&gt;from&lt;/span&gt; route &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; data
               &lt;span style="color: rgb(0,0,255)"&gt;where&lt;/span&gt; route.Key.IndexOf(&lt;span style="color: rgb(163,21,21)"&gt;"Category"&lt;/span&gt;) == 0
               &lt;span style="color: rgb(0,0,255)"&gt;orderby&lt;/span&gt; route.Key
               &lt;span style="color: rgb(0,0,255)"&gt;select&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt;{Key = route.Key, Value = route.Value.ToString()};

    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; sqlSelect = &lt;span style="color: rgb(163,21,21)"&gt;@"
        SELECT {0}.* 
        FROM Category {0}
        {1}
        WHERE {0}.Name = {{0}}"&lt;/span&gt;;
&lt;span style="color: rgb(0,128,0)"&gt;    &lt;br /&gt;    //{{{2}}} will be replaced with {{&amp;lt;param index&amp;gt;}}&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; join = &lt;span style="color: rgb(163,21,21)"&gt;@"INNER JOIN Category {0} ON {0}.[Key] = {1}.ParentKey 
                    AND {0}.[Name] = {{{2}}}

&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt;    //This is the name of the category I am actually interested in&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; mainCat = navList.Last();

    &lt;span style="color: rgb(0,128,0)"&gt;//Build a list of category values to for parameterized query&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(43,145,175)"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;&amp;gt; values = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;&amp;gt;();
    values.Add(mainCat.Value);
    &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt; sb = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt;();
    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; lastCategory = mainCat.Key;

    &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; i = 1;
    &lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; item &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; navList.Reverse().Skip(1))
    {
        sb.AppendFormat(join, item.Key, lastCategory,i++);
        values.Add(item.Value);
        lastCategory = item.Key;
    }

    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; sql = &lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;.Format(sqlSelect,mainCat.Key, sb.ToString());
    &lt;span style="color: rgb(43,145,175)"&gt;Category&lt;/span&gt; cat = &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;.ExecuteQuery&amp;lt;&lt;span style="color: rgb(43,145,175)"&gt;Category&lt;/span&gt;&amp;gt;(sql, values.ToArray()).Single();&lt;br /&gt;
&lt;span style="color: rgb(0,128,0)"&gt;&lt;br /&gt;&lt;br /&gt;    //GetDisplayCategory skips over categories that have only 1 subcategory &lt;br /&gt;    //and no examples, allowing me to have the planned Url structure without &lt;br /&gt;    //&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt;requiring the user to navigate through several empty categories.&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; GetDisplayCategory(cat);
}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;I had planned on having doing it all LINQ to SQL expressions, but it was taking more time then it was worth to figure out how to do the hierarchy lookup from the category names.  I need to add some caching of the key lookups at some point, since the joins look like they might get a bit nasty for deep categories, but that can wait.&lt;/p&gt;
&lt;p&gt;I added a few overloads to the HtmlHelper ActionLink extension methods to handle making the nice Url links.&lt;/p&gt;
&lt;p&gt;Now I need to figure out how to deploy the usercontrols that will contain the executable part of the example. I have had some problems with compilation sometimes when I had the website directly upload the usercontrols. Plus I would like them to go into source control when I add them.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ec42d13d-48c0-4c3f-87a9-08d17c181005" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/aspnetmvc" rel="tag"&gt;aspnetmvc&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/44.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/24/got-my-nice-urls-working.aspx</guid>
            <pubDate>Mon, 24 Dec 2007 15:44:26 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/44.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/24/got-my-nice-urls-working.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/44.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/44.aspx</trackback:ping>
        </item>
        <item>
            <title>Temp service provider implementation</title>
            <link>http://sean-lynch.net/archive/2007/12/18/temp-service-provider-implementation.aspx</link>
            <description>&lt;p&gt;Well, Bill Pierce in his post about making the &lt;a href="http://blechie.com/WPierce/archive/2007/12/16/On-the-Extensibility-of-ASP.Net-MVC.aspx"&gt;HttpContext wrapper use the application as a service provider&lt;/a&gt; got me to a good enough solution for the script service I had wanted in my &lt;a href="http://myheadsexploding.com/archive/2007/12/16/generic-beginend-html-tag-extension-method.aspx"&gt;previous post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While not quite as clean as adding it to the HttpContext, I think an extension method on HttpApplication like this will work well for now. &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public static object &lt;/span&gt;GetService(&lt;span style="COLOR: blue"&gt;this &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;HttpApplication &lt;/span&gt;application,&lt;span style="COLOR: #2b91af"&gt;Type &lt;/span&gt;service)
{
    &lt;span style="COLOR: #2b91af"&gt;IServiceProvider &lt;/span&gt;provider = application &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;IServiceProvider&lt;/span&gt;;
    &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(provider == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
        &lt;span style="COLOR: blue"&gt;return null&lt;/span&gt;;

    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;provider.GetService(service);
}
&lt;/pre&gt;
&lt;p&gt;Then add/implement the IServiceProvider on the Global class. Allowing me to get an instance of the script service using  &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: #2b91af"&gt;IScriptService &lt;/span&gt;scriptSvc &lt;br /&gt;    = &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.HttpContext.ApplicationInstance.GetService(&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;IScriptService&lt;/span&gt;))
    &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;IScriptService&lt;/span&gt;;
&lt;/pre&gt;
&lt;p&gt;Though though the more I think of it, the more likely I am to stick this method on the Ajax and Html helper classes. I wonder how hard it would be to add an interface like IMvcHelper to both the AjaxHelper and HtmlHelper Classes my extension method would be available to both, without duplicating code. &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5b7d24d4-583f-43bb-bb38-8a159374e46f" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/aspnetmvc"&gt;aspnetmvc&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Service%20Provider"&gt;Service Provider&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Extension%20Method"&gt;Extension Method&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/43.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/18/temp-service-provider-implementation.aspx</guid>
            <pubDate>Tue, 18 Dec 2007 23:06:34 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/43.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/18/temp-service-provider-implementation.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/43.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/43.aspx</trackback:ping>
        </item>
        <item>
            <title>I feel so behind sometimes</title>
            <link>http://sean-lynch.net/archive/2007/12/18/i-feel-so-behind-sometimes.aspx</link>
            <description>&lt;p&gt;I was trying to determine the best way to secure my admin* actions when I thought of something I had only really seen while studying for my MCSD.Net exams, or maybe it was the MCPD upgrade exams I haven't gotten round to taking. &lt;/p&gt;
&lt;p&gt;I decided to secure the admin controller actions using.&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="COLOR: rgb(43,145,175)"&gt;PrincipalPermission&lt;/span&gt;(&lt;span style="COLOR: rgb(43,145,175)"&gt;SecurityAction&lt;/span&gt;.Demand,Role=&lt;span style="COLOR: rgb(163,21,21)"&gt;"&amp;lt;Role&amp;gt;"&lt;/span&gt;)] &lt;/pre&gt;
&lt;p&gt;Which I had never used even though I started programming .Net in during the beta of 1.0. And I have to admit that each time I run into something like this, it makes me feel that my thought in &lt;a href="http://myheadsexploding.com/archive/2007/12/11/i-think-the-3.5-framework-might-be-the-straw.aspx"&gt;a previous post&lt;/a&gt; is right.&lt;/p&gt;
&lt;p&gt;This works for my immediate needs, after thinking about it, it would be nice if the Route Validation could deal with security too. That way instead of getting "&lt;em&gt;Security Exception" &lt;/em&gt;when navigating to one of the admin actions, the route would simply not resolve resulting in "&lt;em&gt;An action named 'New could not be found on the controller." &lt;/em&gt;if someone was trying out the obvious Urls for maintenance, since they are rather hackable (from Phil Haack's recent interview on the &lt;a href="http://morewally.com/cs/blogs/wallym/archive/2007/12/14/asp-net-podcast-show-106-phil-haack-on-asp-net-mvc.aspx"&gt;ASP.Net Podcast show&lt;/a&gt; ).  &lt;/p&gt;
&lt;p&gt;Though now that I write that I think it would be better to have it throw the Security Exception, log it, then handle both errors be handle it as a 404 error from then on. That way I can log information of the unauthorized attempts on the admin actions, without telling the outside world anything. So maybe I don't need to be able to specify authentication validation on the routes after all. Though routes based on errors might be nice.&lt;/p&gt;
&lt;p&gt;Now I just need to look up more on custom error pages. &lt;/p&gt;
&lt;p&gt;I really do feel so behind sometimes.&lt;/p&gt;
&lt;p&gt;&lt;font size="1"&gt;* Will be making a post in next few days on this. The dynamic stuff I had started for the &lt;/font&gt;&lt;a href="http://myheadsexploding.com/archive/2007/12/16/generic-beginend-html-tag-extension-method.aspx"&gt;&lt;font size="1"&gt;last post&lt;/font&gt;&lt;/a&gt;&lt;font size="1"&gt; was a bit more usable in the admin area.&lt;/font&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:97c69bff-98a0-4561-b71f-5f38f951c61f" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/aspnetmvc"&gt;aspnetmvc&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/Security"&gt;Security&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/42.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/18/i-feel-so-behind-sometimes.aspx</guid>
            <pubDate>Tue, 18 Dec 2007 13:22:41 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/42.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/18/i-feel-so-behind-sometimes.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/42.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/42.aspx</trackback:ping>
        </item>
        <item>
            <title>Generic begin/end Html tag extension method</title>
            <link>http://sean-lynch.net/archive/2007/12/16/generic-beginend-html-tag-extension-method.aspx</link>
            <description>&lt;p&gt;After working on the login usercontrol, I decided that I wanted to add similar functionality to the navigation sections of the site for accounts/roles that didn't get ads displayed. So I needed a standard way to put dynamic sections into a page.&lt;/p&gt; &lt;p&gt;I liked the syntax used by the form HtmlHelper methods, so decided to base it off of the SimpleForm class and ended up with this&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,128,0)"&gt;//Based on the SimpleForm class in MvcToolkit &lt;br /&gt;&lt;span style="color: rgb(0,128,0)"&gt;//Wish I believed I would have ever thought to use&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt;//IDisposable to do this&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;SimpleWrappingTag&lt;/span&gt; : &lt;span style="color: rgb(43,145,175)"&gt;IDisposable&lt;br /&gt;&lt;/span&gt;{
    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; _beginTagFormat = &lt;span style="color: rgb(163,21,21)"&gt;"&amp;lt;{0} {1}&amp;gt;"&lt;/span&gt;;
    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; _attributeFormat = &lt;span style="color: rgb(163,21,21)"&gt;"{0}=\"{1}\" "&lt;/span&gt;;
    &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; _startTagRendered = &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;;
    &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; _endTagRendered = &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;;
    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;IHttpContext&lt;/span&gt; _context;
    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt; _htmlAttributes = &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;;


    &lt;span style="color: rgb(0,128,0)"&gt;//Not letting this be modified outside the class for now
&lt;/span&gt;    &lt;span style="color: rgb(0,128,0)"&gt;//might change later
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; TagName { &lt;span style="color: rgb(0,0,255)"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;set&lt;/span&gt;; }


    &lt;span style="color: rgb(0,128,0)"&gt;//Subclassed controls can put their class specific info here
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; SimpleWrappingTag(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; tagName)
    {
        &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;.TagName = tagName;
    }
    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; SimpleWrappingTag(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; tagName, &lt;span style="color: rgb(43,145,175)"&gt;IHttpContext&lt;/span&gt; context
        , &lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt; htmlAttributes)
    {
        &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;.TagName = tagName;
        &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._context = context;
        &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._htmlAttributes = htmlAttributes;
    }

    &lt;span style="color: rgb(128,128,128)"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt; &lt;/span&gt;&lt;span style="color: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;
&lt;/span&gt;    &lt;span style="color: rgb(128,128,128)"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt; Creates a StringBuilder and passes it to an overloaded method. 
&lt;/span&gt;    &lt;span style="color: rgb(128,128,128)"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt; Override this method for attributes that should be first in tag.
&lt;/span&gt;    &lt;span style="color: rgb(128,128,128)"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt; &lt;/span&gt;&lt;span style="color: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;
&lt;/span&gt;    &lt;span style="color: rgb(128,128,128)"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0,128,0)"&gt; &lt;/span&gt;&lt;span style="color: rgb(128,128,128)"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;virtual&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt; BuildAttributeList()
    {
        &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; BuildAttributeList(&lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt;());
    }
    &lt;span style="color: rgb(0,0,255)"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;virtual&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt; BuildAttributeList(&lt;span style="color: rgb(43,145,175)"&gt;StringBuilder&lt;/span&gt; sb)
    {
        sb.Append(_htmlAttributes.ToAttributeList());
        &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; sb;
    }
    &lt;span style="color: rgb(0,128,0)"&gt;//Method orginally from SimpleForm, but changed to work with 
&lt;/span&gt;    &lt;span style="color: rgb(0,128,0)"&gt;//BuildAttributeList instead of BuildFormOpenTag
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; WriteStartTag()
    {
        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (!&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._startTagRendered)
        {
            &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; formTag = &lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163,21,21)"&gt;"&amp;lt;{0} {1}&amp;gt;"&lt;/span&gt;, TagName
                , BuildAttributeList());
            &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._context.Response.Write(formTag);
        }
    }
    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; WriteEndTag()
    {
        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (!&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._endTagRendered)
            &lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;._context.Response.Write(&lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163,21,21)"&gt;"&amp;lt;/{0}&amp;gt;"&lt;/span&gt;, TagName));
    }

    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; Dispose()
    {
        WriteEndTag();
    }
}
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;
&lt;p&gt;Next I made some trivial, but needed extension methods for the HtmlHelper class.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;DevExamplesExtensions
&lt;/span&gt;{
    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;IDisposable&lt;/span&gt; HtmlTag(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;HtmlHelper&lt;/span&gt; helper, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; tagName)
    {
        &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; helper.HtmlTag(tagName, &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;);
    }
    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;IDisposable&lt;/span&gt; HtmlTag(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;HtmlHelper&lt;/span&gt; helper
        , &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; tagName, &lt;span style="color: rgb(0,0,255)"&gt;object&lt;/span&gt; htmlAttributes)
    {
        &lt;span style="color: rgb(43,145,175)"&gt;SimpleWrappingTag&lt;/span&gt; tag =  &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;SimpleWrappingTag&lt;/span&gt;(tagName
            , helper.ViewContext.HttpContext, htmlAttributes);
        tag.WriteStartTag();
        &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; tag;
    }
}&lt;/pre&gt;
&lt;p&gt;And while I'm satisfied with how this turned out, though I'm hoping to be able to delete the code at some point, I don't like how the code I wrote to implement an Ajax.UpdatePanel method turned out. So I'm not going to post it at the moment.&lt;/p&gt;
&lt;p&gt;But it was going to look something like&lt;/p&gt;
&lt;p&gt;public static UpdatePanel(this AjaxHelper helper, string panelId, ....)&lt;br /&gt;{&lt;br /&gt;   helper.ViewContext.HttpContext.Write("update panel js....");&lt;br /&gt;   IDisposable tag = new HtmlHelper(helper.ViewContext.HttpContext)&lt;br /&gt;        .HtmlTag("div",new { id=panelId});&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Below is a list of things I couldn't think of a good solution for at the moment&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I didn't like the fact that I was putting the actual JavaScript into the UpdatePanel extension method. Rob Conery said something on the forums about using services to provide the view with site-wide info that seemed interesting, but not sure of a good way to implement this would be. &lt;br /&gt;&lt;br /&gt;It would be nice to have service providers kind of like you can use in Windows Workflow Foundation or VS control designers, that would let me add a IScriptService to do the actual JavaScript coding based on the script library I wanted to use.&lt;br /&gt;&lt;br /&gt;Maybe I should just create a script provider for this. &lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Having to pass in a list of "triggering" controls felt kind of clunky. I'm trying to think of the best way to allow me to specify that a Html.ActionLink should register itself with the "UpdatePanel". &lt;br /&gt;&lt;br /&gt;Most of what I think of for this, basically requires me to implement my own versions of the stuff already implemented in the MvcToolkit.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;I couldn't come up with a clean way to have the panel in the Usercontrol, but only have it be done if the usercontrol is called from a page instead of as a standalone view. I guess I could have the controller tell it this, but ideally they would just kind of know.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;I think I may have already thought of the solution #3, and a workable #2. But I am really hesitant to do anything with #1 (outside the provider maybe) since I doubt I would do it close enough that I wouldn't need to remove it all to move over to their way, should they implement something like service providers.&lt;/p&gt;
&lt;p&gt;I think I'm going to put this aside for a while on another part of the site, this just is a "nice to have" feature, and get some of the other pieces that I actually need to have for the site done.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bef9a321-fa1c-4958-9988-76286d94e67d" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/aspnetmvc" rel="tag"&gt;aspnetmvc&lt;/a&gt;, &lt;a href="http://technorati.com/tags/HtmlHelper%20Extensions" rel="tag"&gt;HtmlHelper Extensions&lt;/a&gt;&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;font size="1"&gt;* 4 actually, but I said how I wished I could &lt;a href="http://myheadsexploding.com/archive/2007/12/06/anonymous-types-and-interfaces.aspx"&gt;implement an interface using an anonymous type&lt;/a&gt;.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/41.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/16/generic-beginend-html-tag-extension-method.aspx</guid>
            <pubDate>Sun, 16 Dec 2007 12:32:02 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/41.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/16/generic-beginend-html-tag-extension-method.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/41.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/41.aspx</trackback:ping>
        </item>
        <item>
            <title>Login via Usercontrol View + jQuery</title>
            <link>http://sean-lynch.net/archive/2007/12/14/login-via-usercontrol-view--jquery.aspx</link>
            <description>&lt;p&gt;Since administration was the next part I wanted to work on.&lt;/p&gt;
&lt;p&gt;I decided that for the moment I just want a little login for in the upper corner like&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_2.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="191" alt="image" width="232" border="0" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I decided to put the login screen view logic into a user control, and added the following user control named Login.ascx and placed it into the Shared &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;@&lt;/span&gt; &lt;span style="COLOR: rgb(163,21,21)"&gt;Control&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;Language&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="C#"&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;Inherits&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="System.Web.Mvc.ViewUserControl"&lt;/span&gt; &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;

&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;if&lt;/span&gt;(!Page.User.Identity.IsAuthenticated) {&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;
&lt;/span&gt;    &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;form&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;action&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="/Home/Login"&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;method&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="post"&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;id&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="LoginForm"&amp;gt;
&lt;/span&gt;        &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;id&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="EmailLabel"&amp;gt;&lt;/span&gt;Username:&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;br&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;
&lt;/span&gt;        &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Html.TextBox(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Username"&lt;/span&gt;)&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;br&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;
&lt;/span&gt;        &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;id&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="PasswordLabel"&amp;gt;&lt;/span&gt;Password:&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;br&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;
&lt;/span&gt;        &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Html.Password(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Password"&lt;/span&gt;)&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;br&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;
&lt;/span&gt;         &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;id&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="Error"&amp;gt;
&lt;/span&gt;            &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;ViewData.ContainsDataItem(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Message"&lt;/span&gt;) ? ViewData[&lt;span style="COLOR: rgb(163,21,21)"&gt;"Message"&lt;/span&gt;] + &lt;br /&gt;               &lt;span style="COLOR: rgb(163,21,21)"&gt;"&amp;lt;BR /&amp;gt;"&lt;/span&gt; : &lt;span style="COLOR: rgb(163,21,21)"&gt;""&lt;/span&gt;&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;
&lt;/span&gt;        &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;
&lt;/span&gt;        &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Html.SubmitButton(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Submit"&lt;/span&gt;, &lt;span style="COLOR: rgb(163,21,21)"&gt;"Login"&lt;/span&gt;)&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;
&lt;/span&gt;    &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;form&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;/span&gt;}&lt;span style="COLOR: rgb(0,0,255)"&gt;else&lt;/span&gt; {&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;
&lt;/span&gt;        &lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;Not &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Page.User.Identity.Name &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;br&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;    
        &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Html.ActionLink&amp;lt;DevExamples.Controllers.&lt;span style="COLOR: rgb(43,145,175)"&gt;HomeController&lt;/span&gt;&amp;gt;(c =&amp;gt; c.Logout()
            , &lt;span style="COLOR: rgb(163,21,21)"&gt;"Logout"&lt;/span&gt;, &lt;span style="COLOR: rgb(0,0,255)"&gt;new&lt;/span&gt; { id = &lt;span style="COLOR: rgb(163,21,21)"&gt;"LogoutLink"&lt;/span&gt; })&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;span&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;

&lt;/span&gt;&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;/span&gt;} &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;And added the user control to the masterpage using &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;div&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;id&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="Login"&amp;gt;&lt;/span&gt;&lt;span style="BACKGROUND: rgb(255,238,98)"&gt;&amp;lt;%&lt;span style="COLOR: rgb(0,0,255)"&gt;&lt;/span&gt;=&lt;/span&gt;Html.RenderUserControl(&lt;span style="COLOR: rgb(163,21,21)"&gt;"~/Views/Shared/Login.ascx"&lt;/span&gt;) &lt;span style="BACKGROUND: rgb(255,238,98)"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;&amp;lt;div&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;I was going to use&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;using&lt;/span&gt; (Html.Form&amp;lt;DevExamples.Controllers.&lt;span style="COLOR: rgb(43,145,175)"&gt;HomeController&lt;/span&gt;&amp;gt;(c=&amp;gt;c.Login()&lt;br /&gt;   ,System.Web.Mvc.&lt;span style="COLOR: rgb(43,145,175)"&gt;FormExtensions&lt;/span&gt;.&lt;span style="COLOR: rgb(43,145,175)"&gt;FormMethod&lt;/span&gt;.post,&lt;span style="COLOR: rgb(0,0,255)"&gt;new&lt;/span&gt; {id=&lt;span style="COLOR: rgb(163,21,21)"&gt;"LoginForm"&lt;/span&gt;}))&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;to create the form (because it is a lot cooler), but couldn't get the html attributes to work and was more interested in getting the dynamic stuff working then looking at the code for the extension method in the MVCToolKit, in other words being lazy.&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;I thought about putting the authentication checking logic into the controller. But handling it this way made it a bit simpler, and more self contained, so until I find a compelling enough reason I will be leaving it this way.&lt;/p&gt;
&lt;p&gt;After I had the user control showing up, I decided to hook up the actual authentication. I decided to go with forms authentication, and set it up using the &lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_4.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="19" alt="image" width="20" border="0" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_thumb_1.png" /&gt;&lt;/a&gt; button in the solution explorer. &lt;/p&gt;
&lt;p&gt;Next it was time to create the login and logout controller actions, which I decided would best fit in the HomeController, At first I had thought to create two separate views, one for when logged in and one for logged out, then remembered &lt;a href="http://haacked.com/"&gt;Phil Haack&lt;/a&gt;, at least I think it was him, something about being able to use user controls in the RenderView method of the controller. &lt;/p&gt;
&lt;p&gt;I ended up with the following two controller actions:&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="COLOR: rgb(43,145,175)"&gt;ControllerAction&lt;/span&gt;]
&lt;span style="COLOR: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;void&lt;/span&gt; Login()
{
    &lt;span style="COLOR: rgb(0,0,255)"&gt;if&lt;/span&gt; (!ControllerContext.HttpContext.User.Identity.IsAuthenticated)
    {
        &lt;span style="COLOR: rgb(0,0,255)"&gt;if&lt;/span&gt; (Request.RequestType == &lt;span style="COLOR: rgb(163,21,21)"&gt;"POST"&lt;/span&gt;)
        {
            &lt;span style="COLOR: rgb(0,0,255)"&gt;string&lt;/span&gt; userName = Request.Form[&lt;span style="COLOR: rgb(163,21,21)"&gt;"Username"&lt;/span&gt;];
            &lt;span style="COLOR: rgb(0,0,255)"&gt;string&lt;/span&gt; password = Request.Form[&lt;span style="COLOR: rgb(163,21,21)"&gt;"Password"&lt;/span&gt;];

            &lt;span style="COLOR: rgb(0,0,255)"&gt;if&lt;/span&gt; (&lt;span style="COLOR: rgb(43,145,175)"&gt;Membership&lt;/span&gt;.ValidateUser(userName, password))
            {
                &lt;span style="COLOR: rgb(43,145,175)"&gt;FormsAuthentication&lt;/span&gt;.SetAuthCookie(userName, &lt;span style="COLOR: rgb(0,0,255)"&gt;true&lt;/span&gt;);
                &lt;span style="COLOR: rgb(0,128,0)"&gt;//Set cookie and redirect
&lt;/span&gt;                RedirectToAction(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Login"&lt;/span&gt;);
            }
            &lt;span style="COLOR: rgb(0,0,255)"&gt;else
&lt;/span&gt;            {
                ViewData.Add(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: rgb(163,21,21)"&gt;"Invalid Username/Password"&lt;/span&gt;);
            }
        }
    }
    RenderView(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Login"&lt;/span&gt;);
}
[&lt;span style="COLOR: rgb(43,145,175)"&gt;ControllerAction&lt;/span&gt;]
&lt;span style="COLOR: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;void&lt;/span&gt; Logout()
{
    &lt;span style="COLOR: rgb(43,145,175)"&gt;FormsAuthentication&lt;/span&gt;.SignOut();
    RedirectToAction(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Login"&lt;/span&gt;);
}
&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Since it was allowing me to just render out the user control, I decided there was no point to refreshing the whole page, so decided to use a AJAXish way of doing it. So I decided it was time to pick a javascript library. And since &lt;a href="http://haacked.com/archive/2007/12/13/thank-you-for-helping-me-with-my-job-with-asp.net.aspx"&gt;Phil had provided a link&lt;/a&gt; to  &lt;a href="http://www.chadmyers.com/Blog/archive/2007/12/10/using-script.aculo.us-with-asp.net-mvc.aspx"&gt;Using script.aculo.us with ASP.NET MVC&lt;/a&gt; by Chad Myers,I decided to go with jQuery for this (that and it seemed to fit better). &lt;/p&gt;
&lt;p&gt;After a bit of reading through their tutorials I added this to the header section of the master page.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;src&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="../../Content/jquery.js"&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;type&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="text/javascript"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;src&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="../../Content/jquery.form.js"&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;type&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="text/javascript"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt; &lt;span style="COLOR: rgb(255,0,0)"&gt;type&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;="text/javascript"&amp;gt;
&lt;/span&gt;    &lt;span style="COLOR: rgb(0,0,255)"&gt;var&lt;/span&gt; readyFuncs = &lt;span style="COLOR: rgb(0,0,255)"&gt;function&lt;/span&gt;() { 
        $(&lt;span style="COLOR: rgb(163,21,21)"&gt;'#LoginForm'&lt;/span&gt;).ajaxForm(&lt;span style="COLOR: rgb(0,0,255)"&gt;function&lt;/span&gt;(result) { 
            $(&lt;span style="COLOR: rgb(163,21,21)"&gt;'#Login'&lt;/span&gt;).html(result); 
            $(document).ready(readyFuncs); 
        }); 
        $(&lt;span style="COLOR: rgb(163,21,21)"&gt;'#LogoutLink'&lt;/span&gt;).click(&lt;span style="COLOR: rgb(0,0,255)"&gt;function&lt;/span&gt;(){
            $.&lt;span style="COLOR: rgb(0,0,255)"&gt;get&lt;/span&gt;(&lt;span style="COLOR: rgb(163,21,21)"&gt;'/Home/Logout'&lt;/span&gt;,&lt;span style="COLOR: rgb(0,0,255)"&gt;function&lt;/span&gt;(result){
                $(&lt;span style="COLOR: rgb(163,21,21)"&gt;'#Login'&lt;/span&gt;).html(result);
                $(document).ready(readyFuncs); 
            });
            &lt;span style="COLOR: rgb(0,0,255)"&gt;return&lt;/span&gt; &lt;span style="COLOR: rgb(0,0,255)"&gt;false&lt;/span&gt;;
        });
    };
    $(document).ready(readyFuncs);
&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: rgb(163,21,21)"&gt;script&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The only real snag I had run into with this was that each time the Login div was refreshed I had to reregister the events.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4dd497a4-51ee-4f9b-a55b-e2bd0856f320" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/aspnetmvc"&gt;aspnetmvc&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/jQuery"&gt;jQuery&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/FormsAuthentication"&gt;FormsAuthentication&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/40.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/14/login-via-usercontrol-view--jquery.aspx</guid>
            <pubDate>Fri, 14 Dec 2007 12:16:51 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/40.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/14/login-via-usercontrol-view--jquery.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/40.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/40.aspx</trackback:ping>
        </item>
        <item>
            <title>Routing revisited</title>
            <link>http://sean-lynch.net/archive/2007/12/13/routing-revisited.aspx</link>
            <description>&lt;p&gt;It turned out to be a lot easier to work around not being able to &lt;a href="http://myheadsexploding.com/archive/2007/12/12/initial-thoughts-on-microsoft-mvc.aspx"&gt;override the route parsing method&lt;/a&gt; then I had thought it would be last night. Though when they allow me to override that method I will be changing over.&lt;/p&gt; &lt;p&gt;By setting up the following routes I was able to get almost the effect that I was looking for:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(43,145,175)"&gt;RouteTable&lt;/span&gt;.Routes.Add(&lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Route
&lt;/span&gt;{
    Url = &lt;span style="color: rgb(163,21,21)"&gt;"Example/[id]/[action]"&lt;/span&gt;,
    Defaults = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; { Controller = &lt;span style="color: rgb(163,21,21)"&gt;"Example"&lt;/span&gt; },
    RouteHandler = &lt;span style="color: rgb(0,0,255)"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43,145,175)"&gt;MvcRouteHandler&lt;/span&gt;)
});

&lt;span style="color: rgb(43,145,175)"&gt;RouteTable&lt;/span&gt;.Routes.Add(&lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Route
&lt;/span&gt;{
    Url = &lt;span style="color: rgb(163,21,21)"&gt;"Example/[Category1]/[id]/[action]"&lt;/span&gt;,
    Defaults = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; { Controller = &lt;span style="color: rgb(163,21,21)"&gt;"Example"&lt;/span&gt; },
    RouteHandler = &lt;span style="color: rgb(0,0,255)"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43,145,175)"&gt;MvcRouteHandler&lt;/span&gt;)
});

&lt;span style="color: rgb(43,145,175)"&gt;RouteTable&lt;/span&gt;.Routes.Add(&lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;Route
&lt;/span&gt;{
    Url = &lt;span style="color: rgb(163,21,21)"&gt;"Example/[Category1]/[Category2]/[id]/[action]"&lt;/span&gt;,
    Defaults = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; { Controller = &lt;span style="color: rgb(163,21,21)"&gt;"Example"&lt;/span&gt; },
    RouteHandler = &lt;span style="color: rgb(0,0,255)"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43,145,175)"&gt;MvcRouteHandler&lt;/span&gt;)
});&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Though the execute action just takes the id in&lt;/p&gt;&lt;pre class="code"&gt;[&lt;span style="color: rgb(43,145,175)"&gt;ControllerAction&lt;/span&gt;]
&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; Execute(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; id)
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;If I find that I actually need access to the Categories found in the path, I can access them using RouteData.Values. It also helps that I had decided that the examples should have a unique ID, that will be a lot like the friendly Urls used in &lt;a href="http://subtextproject.com"&gt;Subtext&lt;/a&gt;. That way the directories are there more for aesthetics then utility. Though when the ability to override the route parsing, I will probably be changing it to this if possible later:&lt;/p&gt;
&lt;p&gt;[&lt;span style="color: rgb(43,145,175)"&gt;ControllerAction&lt;/span&gt;] &lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; Execute(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; id, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;[] categories) &lt;/p&gt;
&lt;p&gt;So now that I have the site navigation working the way that I want it, with the exception of a helper method for writing out the longer category listings, its time to work on the maintenance parts of the site.&lt;/p&gt;
&lt;p&gt;And so far it seems that this will be a better fit then WebForms was for the last few reworks of the site, since I can make the UserControls containing the examples completely isolated, including having the runat server form in the control. The only one I liked better was the JSON based one, using ASP.Net AJAX Extensions, which would have gone live if AdSense worked with AJAX/JSON sites.&lt;/p&gt;
&lt;p&gt;Overall the more I use it the more I like the feel of the framework. Especially now that I realized which of these  I wanted to selected when using a master page.&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/MicrosoftMVCandtheRoute_1480D/image_6.png"&gt;&lt;br /&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="46" alt="image" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/MicrosoftMVCandtheRoute_1480D/image_thumb_2.png" width="186" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And so far the best part of the framework is that I don't have to ignore features to not see this dialog after refreshing the page I just navigated to.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/MicrosoftMVCandtheRoute_1480D/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="162" alt="image" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/MicrosoftMVCandtheRoute_1480D/image_thumb_1.png" width="307" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:397fa6d3-28ca-4423-8bdc-fba968814994" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/aspnetmvc" rel="tag"&gt;aspnetmvc&lt;/a&gt;&lt;/div&gt;&lt;img src="http://sean-lynch.net/aggbug/39.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/12/13/routing-revisited.aspx</guid>
            <pubDate>Thu, 13 Dec 2007 12:12:00 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/39.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/12/13/routing-revisited.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/39.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/39.aspx</trackback:ping>
        </item>
    </channel>
</rss>