<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>Learning</title>
        <link>http://sean-lynch.net/category/8.aspx</link>
        <description>Learning</description>
        <language>en-US</language>
        <copyright>Sean Lynch</copyright>
        <managingEditor>slynch13@gmail.com</managingEditor>
        <generator>Subtext Version 2.0.0.9</generator>
        <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>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>I think reading is ruining my job</title>
            <link>http://sean-lynch.net/archive/2007/09/03/i-think-reading-is-ruining-my-job.aspx</link>
            <description>&lt;p&gt;Back in May I decided that I was going to &lt;a href="http://myheadsexploding.com/archive/2007/05/06/building-the-sit-and-read-muscle.aspx"&gt;start reading more&lt;/a&gt;. Admittedly my dedication to this has been nowhere near what &lt;a href="http://graysmatter.codivation.com/HowIAmBecomingABetterDeveloperPart1OfInfinity.aspx"&gt;Justice Gray's&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;Since that first post I have: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Read 3 and 8/3rds tech related books &lt;/li&gt; &lt;li&gt;Listened to almost every &lt;a href="http://dotnetrocks.com/"&gt;.NET Rocks!&lt;/a&gt; (which I had already been listening to for a few years) and many of &lt;a href="http://runasradio.com/"&gt;RunAs Radio&lt;/a&gt; shows&lt;/li&gt; &lt;li&gt;Skimming the &lt;a href="http://blogs.msdn.com"&gt;MSDN main feed&lt;/a&gt;  for things that looked interesting. &lt;/li&gt; &lt;li&gt;Reading 25 or so mostly development blogs, thankfully &lt;a href="http://ayende.com/Blog/Default.aspx"&gt;Ayende&lt;/a&gt; is the only one who averages more then one post per day or I would never get anything done.&lt;/li&gt; &lt;li&gt;Reading through the source of a couple of open source projects I use, and submitted a patch to the &lt;a href="http://subtextproject.com/"&gt;Subtext project&lt;/a&gt; (hopefully it wasn't crap).&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I have learned a lot. &lt;/p&gt; &lt;p&gt;Unfortunately it has been steadily reducing my job satisfaction. While some of it stems from working with a foundation I wrote in .Net 1.0 before having ever actually worked with tiered architecture, and I'm sure that a lot of it is also the "grass is greener on the other side" syndrome, I have been slowly noticing rather important deficiencies in my coding experience. &lt;/p&gt; &lt;p&gt;Chief among them are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;No form of automatic testing or validation. This one probably isn't here for the reason that most people would think, because it improves code quality. Its here because having developers spend a day or two manually retesting a section of the program, rather then spending that day or two automating the testing seems to help &lt;a href="http://en.wikipedia.org/wiki/Parkinson%27s_Law"&gt;Parkinson's Law&lt;/a&gt; when there is no impending next task.&lt;/li&gt; &lt;li&gt;Platform backwards compatibility. While I completely understand why we need to still support SQL 2000, and completely agree with it too, it still makes me weep inside a little when I read the features in SQL 2005/8. &lt;/li&gt; &lt;li&gt;Most of what I do has little value elsewhere. Admittedly most of this one is kind of my fault, but I'll plead ignorance as my excuse. My boss is rather adamant that we only use control that we develop, or the comes from Microsoft. And since with .Net 1.0 there was no AJAX support built in, we recreated just about every ASP.Net control again, most inheriting from WebControl (I really wish .Net had multiple inheritance). &lt;/li&gt; &lt;li&gt;No real experience with cross browser support. This one is completely my fault, well 99.95% my boss did have to agree with it. For this one I plead Netscape 4.x and very heavy JavaScript/Dynamic HTML, and now there just is not enough justification to change it.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Now it is a very nice place to work, which combined with a rather intense dislike for job hunting means that I'm not highly likely to try to solve these problems by searching for a new job. Which might be a good thing, since it requires me to improve in areas outside of design/coding. &lt;/p&gt; &lt;p&gt;Hopefully I can avoid becoming &lt;a href="http://www.yafla.com/dennisforbes/Effectively-Integrating-Into-Software-Development-Teams/Effectively-Integrating-Into-Software-Development-Teams.html"&gt;the fictional guy&lt;/a&gt; who sent Dennis Forbes, and recently talked about on &lt;a href="http://www.codinghorror.com/blog/archives/000933.html"&gt;coding horror&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/23.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/09/03/i-think-reading-is-ruining-my-job.aspx</guid>
            <pubDate>Mon, 03 Sep 2007 12:48:58 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/23.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/09/03/i-think-reading-is-ruining-my-job.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/23.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/23.aspx</trackback:ping>
        </item>
        <item>
            <title>Still not sure, but it can be learned</title>
            <link>http://sean-lynch.net/archive/2007/08/28/still-not-sure-but-it-can-be-learned.aspx</link>
            <description>&lt;p&gt;I doubt I actually had anything direct to do with it but something seems to have clicked with one of the junior developers. I'm pretty sure it wasn't something that I had done, other then figuring out an effective way to make him realize that it is in his best interest to not need me to walk him through things. &lt;/p&gt; &lt;p&gt;Nothing threatening, simply reminding him of a couple of thing:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;I brought up that I had basically reached a plateau at the company, and that I was considering pursuing other opportunities (In fact I'm planing on talking to my boss about this tomorrow).    &lt;/li&gt;&lt;li&gt;I pointed out that if I or my boss have to walk them through the entire change, especially more then once, he wasn't really needed.  &lt;/li&gt;&lt;li&gt;I fixed my attitude, unfortunately it involved &lt;a title="Dynamics of software development by Jim McCarthy" href="http://http://www.amazon.com/gp/product/0735623198?ie=UTF8&amp;amp;tag=aspexamplesco-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0735623198" rel="nofollow"&gt;"flipping the bozo bit"&lt;/a&gt; a little.  &lt;/li&gt;&lt;li&gt;I had him answer all of the newer junior developers questions for a day.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Truthfully, I think it was the last two parts that made the difference. Both yesterday and today I was able to answer most of his questions by pointing him towards areas in the code which implemented similar functionality, and he was able to take it from there. Saving me the 10-30 minutes while I tried to explain how to implement it.&lt;/p&gt; &lt;p&gt;Now I just need to figure out how to get them to look beyond the source file they are working in at the time.&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/22.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/08/28/still-not-sure-but-it-can-be-learned.aspx</guid>
            <pubDate>Wed, 29 Aug 2007 11:54:10 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/22.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/08/28/still-not-sure-but-it-can-be-learned.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/22.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/22.aspx</trackback:ping>
        </item>
        <item>
            <title>Can working with others code be taught? </title>
            <link>http://sean-lynch.net/archive/2007/08/26/can-working-with-others-code-be-taught.aspx</link>
            <description>&lt;p&gt;For the last few months I have been trying to figure out how to be able to answer yes to this question. Unfortunately I have also been failing rather spectacularly at it, the junior programmers my boss hired and assigned me as something of a mentor for have shown very little improvement (sometimes even getting worse). &lt;/p&gt;
&lt;p&gt;Unfortunately I was "gifted" with the ability to work with other peoples code, at least when I have some clue as to the intent. Now before you start saying "oh how nice for you", it wasn't said to brag, it was an excuse I keep telling myself for not being able to help them. I mean the only thing someone "gifted" with a talent would have to brag about would be something like "my &amp;lt;insert your deity&amp;gt; loves me more then you", which is just childish. &lt;/p&gt;
&lt;p&gt;I'm sure part of it is that both of them are "at work only" programmers, so the likelihood of them doing anything listed on any of the &lt;a href="http://weblogs.asp.net/bsimser/archive/2007/07/05/being-a-better-developer-in-6-months.aspx"&gt;being a better developer&lt;/a&gt; lists that had been going around a few months ago. As of late I have been finding myself acting more and more like a the Jeff Atwood suggests might been needed in &lt;a href="http://www.codinghorror.com/blog/archives/000931.html"&gt;coding discipline enforcer&lt;/a&gt; then a mentor and thats not doing anyone any good.&lt;/p&gt;
&lt;p&gt;Anyways, if you have found an effective method for teaching others this talent feel free to share it. I'm getting tired of feeling like my collage statistics teacher.&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/21.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/08/26/can-working-with-others-code-be-taught.aspx</guid>
            <pubDate>Mon, 27 Aug 2007 11:20:01 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/21.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/08/26/can-working-with-others-code-be-taught.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/21.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/21.aspx</trackback:ping>
        </item>
        <item>
            <title>WF and WCF books</title>
            <link>http://sean-lynch.net/archive/2007/08/26/wf-and-wcf-books.aspx</link>
            <description>&lt;p&gt;I have read most of the &lt;a href="http://www.amazon.com/gp/product/0321399838?ie=UTF8&amp;amp;tag=aspexamplesco-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0321399838"&gt;Essential Windows Workflow Foundation&lt;/a&gt;&lt;img style="MARGIN: 0px; BORDER-TOP-STYLE: none! important; BORDER-RIGHT-STYLE: none! important; BORDER-LEFT-STYLE: none! important; BORDER-BOTTOM-STYLE: none! important" height="1" alt="" width="1" border="0" src="http://www.assoc-amazon.com/e/ir?t=aspexamplesco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0321399838" /&gt; book by Dharma Shukla and Bob Schmidt. I would definitely recommend it for anyone who is just starting with WF or who is just curious as to the why features were implemented a certain way. This book probably is not for you however if you are looking for a more hands on book.&lt;/p&gt;
&lt;p&gt;Which brings me to the next book, which I wish I had started first, &lt;a href="http://www.amazon.com/gp/product/0596101627?ie=UTF8&amp;amp;tag=aspexamplesco-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0596101627"&gt;Learning WCF: A Hands-on Guide&lt;/a&gt;&lt;img style="MARGIN: 0px; BORDER-TOP-STYLE: none! important; BORDER-RIGHT-STYLE: none! important; BORDER-LEFT-STYLE: none! important; BORDER-BOTTOM-STYLE: none! important" height="1" alt="" width="1" border="0" src="http://www.assoc-amazon.com/e/ir?t=aspexamplesco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0596101627" /&gt; by &lt;a href="http://www.thatindigogirl.com"&gt;Michele Leroux Bustamante&lt;/a&gt;. While a lot of the information in the book is available on the web, having the information pre-filtered, there is a lot of beta 3.0 stuff out there still and with 3.5 there is even more noise out there. So far this book has been very hands on, normally only a page or two before going into another lab. &lt;/p&gt;
&lt;p&gt;So far the only complaint I have about the book is the amount of effort it is likely to take not to put it aside after the first few chapters, in fact the subconscious pressure to start running a muck with WCF started within the first 50 or so pages. Followed by a slight feeling of sadness in that I will likely never get to use what I learn in my day job.&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/20.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/08/26/wf-and-wcf-books.aspx</guid>
            <pubDate>Mon, 27 Aug 2007 10:31:23 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/20.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/08/26/wf-and-wcf-books.aspx#feedback</comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/20.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/20.aspx</trackback:ping>
        </item>
        <item>
            <title>Building my "sit and read" muscle</title>
            <link>http://sean-lynch.net/archive/2007/05/06/building-the-sit-and-read-muscle.aspx</link>
            <description>&lt;div&gt;&lt;span style="FONT-SIZE: 9pt"&gt;After doing some spring cleaning over the last few weeks, I have found that I had a stack of books on various topics that I had meant at one point to read. I also decided that I would like to actually read most of them, but am finding that I have a relatively weak "sit and read muscle". Looking back I’m not all that surprised by this fact, though I am a little annoyed with myself because of it (and determined to fix it). This does however seem to only be effect non-fiction reading.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Its not so much that my "sit and read muscle" is weak that annoys me, rather how “natural” most other forms of "sit and &amp;lt; activity&amp;gt;" tends to feel. I probably couldn’t count the number of times that I just sat and watched TV, in fact I often found I needed to put effort into stopping. At first I thought this might be a passive vs. active participation thing, until I thought about gaming. Since I was young I can remember periods where I would sit in front of the TV/computer and going 5-10 hours without ever moving, outside of the hand/finger motions required to control the game. &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 9pt"&gt;In fact about the only “sit and &amp;lt;activity&amp;gt; muscle” that is as weak is my “sit and writing muscle”. I suspect that the reasons behind the two are rather similar, likely related to how much active thought needs to go into. I suspect that part of it is tied to the fact that productive thinking tends to generate physical energy for me, which is why my leg tends to shake when I am in the zone programming. This would seem to fit with the problem, since generally the biggest obstacle to both reading and writing human languages (English) is a urge to get up and move which slowly increases in intensity.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 9pt"&gt;I think to test this theory; I will try doing more reading on my exercise bike. Hopefully it will work since that would be a good amount of paper to have wasted by not reading them. It will also have the added benefit of more exercise.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 9pt"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;&lt;img height="320" alt="The books" width="240" src="/images/myheadsexploding_com/12/r_IMAGE_00047.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sean-lynch.net/aggbug/18.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sean Lynch</dc:creator>
            <guid>http://sean-lynch.net/archive/2007/05/06/building-the-sit-and-read-muscle.aspx</guid>
            <pubDate>Mon, 07 May 2007 09:09:39 GMT</pubDate>
            <wfw:comment>http://sean-lynch.net/comments/18.aspx</wfw:comment>
            <comments>http://sean-lynch.net/archive/2007/05/06/building-the-sit-and-read-muscle.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://sean-lynch.net/comments/commentRss/18.aspx</wfw:commentRss>
            <trackback:ping>http://sean-lynch.net/services/trackbacks/18.aspx</trackback:ping>
        </item>
    </channel>
</rss>