<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Tim Barcz - MVC</title>
    <link>http://www.timbarcz.com/blog/</link>
    <description>My Code is My Craft</description>
    <image>
      <url>http://www.timbarcz.com/blog/content/binary/channelImage.jpg</url>
      <title>Tim Barcz - MVC</title>
      <link>http://www.timbarcz.com/blog/</link>
    </image>
    <language>en-us</language>
    <copyright>Tim Barcz</copyright>
    <lastBuildDate>Tue, 23 Sep 2008 02:54:35 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>blog@timbarcz.com</managingEditor>
    <webMaster>blog@timbarcz.com</webMaster>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=169788ee-ef28-4b18-ae77-d3d9fd3c797e</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,169788ee-ef28-4b18-ae77-d3d9fd3c797e.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,169788ee-ef28-4b18-ae77-d3d9fd3c797e.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=169788ee-ef28-4b18-ae77-d3d9fd3c797e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yeah this is old hat, I know.  The <a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16775">Preview
5 release</a> was news about three weeks ago.  There wasn't a need for me to
upgrade until today.  Both <a href="http://devlicio.us/blogs/derik_whittaker/">Derik</a> and <a href="http://devlicio.us/blogs/casey/">Casey</a> did
great write-ups on some of the issues in migrating from Preview 4 to Preview 5 (found <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/09/03/upgrading-dimecasts-net-from-mvc-preview-4-to-preview-5.aspx">here</a> and <a href="http://devlicio.us/blogs/casey/archive/2008/09/02/problems-upgrading-asp-net-mvc-to-preview-5.aspx">here</a> respectively). 
I've been using their posts to assist in the transition.  However, as I was making
the move I kept getting the following error:
</p>
        <blockquote>
          <p>
Could not load file or assembly 'System.Web.Routing, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040) 
<br />
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.
</p>
        </blockquote>
        <p>
I was following the advice that both Casey and Derik laid out for upgrading the web.config
of all old System.Web.Routing references and yet I was still getting the error. 
I could search the whole solution for "0.0.0.0" and not a single result
would be found.
</p>
        <p>
Turns out that in my haste I forgot to upgrade the MvcContrib library that we are
also using.  It had a reference to System.Web.Routing (0.0.0.0).  So it
was a little oversight on my part and after I upgraded to the latest MvcContrib, I
was back on my way to upgrading, routing problem solved.
</p>
        <p>
Cheers!
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=169788ee-ef28-4b18-ae77-d3d9fd3c797e" />
      </body>
      <title>Upgrading to MVC Preview 5 - System.Web.Routing problem</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,169788ee-ef28-4b18-ae77-d3d9fd3c797e.aspx</guid>
      <link>http://www.timbarcz.com/blog/UpgradingToMVCPreview5SystemWebRoutingProblem.aspx</link>
      <pubDate>Tue, 23 Sep 2008 02:54:35 GMT</pubDate>
      <description>&lt;p&gt;
Yeah this is old hat, I know.&amp;#160; The &lt;a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16775"&gt;Preview
5 release&lt;/a&gt; was news about three weeks ago.&amp;#160; There wasn't a need for me to
upgrade until today.&amp;#160; Both &lt;a href="http://devlicio.us/blogs/derik_whittaker/"&gt;Derik&lt;/a&gt; and &lt;a href="http://devlicio.us/blogs/casey/"&gt;Casey&lt;/a&gt; did
great write-ups on some of the issues in migrating from Preview 4 to Preview 5 (found &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/09/03/upgrading-dimecasts-net-from-mvc-preview-4-to-preview-5.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://devlicio.us/blogs/casey/archive/2008/09/02/problems-upgrading-asp-net-mvc-to-preview-5.aspx"&gt;here&lt;/a&gt; respectively).&amp;#160;
I've been using their posts to assist in the transition.&amp;#160; However, as I was making
the move I kept getting the following error:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Could not load file or assembly 'System.Web.Routing, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040) 
&lt;br /&gt;
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I was following the advice that both Casey and Derik laid out for upgrading the web.config
of all old System.Web.Routing references and yet I was still getting the error.&amp;#160;
I could search the whole solution for &amp;quot;0.0.0.0&amp;quot; and not a single result
would be found.
&lt;/p&gt;
&lt;p&gt;
Turns out that in my haste I forgot to upgrade the MvcContrib library that we are
also using.&amp;#160; It had a reference to System.Web.Routing (0.0.0.0).&amp;#160; So it
was a little oversight on my part and after I upgraded to the latest MvcContrib, I
was back on my way to upgrading, routing problem solved.
&lt;/p&gt;
&lt;p&gt;
Cheers!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=169788ee-ef28-4b18-ae77-d3d9fd3c797e" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,169788ee-ef28-4b18-ae77-d3d9fd3c797e.aspx</comments>
      <category>MVC</category>
      <category>Tips &amp; Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=94fe3fa1-2acf-4e91-a316-d2d8aaf4d010</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,94fe3fa1-2acf-4e91-a316-d2d8aaf4d010.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,94fe3fa1-2acf-4e91-a316-d2d8aaf4d010.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=94fe3fa1-2acf-4e91-a316-d2d8aaf4d010</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Have you ever been traveling through the "internets" and have been presented
with the following?
</p>
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_2.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="166" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb.png" width="374" border="0" />
          </a>
        </p>
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_8.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb_3.png" width="562" border="0" />
          </a>
        </p>
        <p>
As web developers we know what this means; a form was posted to the page and now you're
trying to refresh that same page.  I'm not sure if there's been any significant
usability study on the subject but I would imagine my Grandmother wouldn't know what
to do here.  Enter the PRG pattern.
</p>
        <h2>
        </h2>
        <h2>What is the PRG Pattern?
</h2>
        <p>
While the PRG pattern isn't knew, there isn't much out there on it for the .NET community. 
PRG stands for "Post/Redirect/Get", I'll let Wikipedia explain the rest:
</p>
        <blockquote>
          <p>
instead of returning an HTML page directly, the POST operation returns a redirection
command (using the HTTP 303 response code (sometimes 302) together with the HTTP "Location"
response header), instructing the browser to load a different page using an HTTP GET
request. The result page can then safely be bookmarked or reloaded without unexpected
side effects.
</p>
        </blockquote>
        <p>
While this could be accomplished in webforms, it would be much more difficult since
the postback model hangs on pages posting to themselves to implement button clicks
and the like.  The MVC Framework on the other hand makes the implementation of
the PRG pattern extremely easy.  
</p>
        <h2>But How?  Can I See an Example?
</h2>
        <p>
I'm going to use an Login function as an example.  If the login attempt is successful,
the user should be redirected to their account page, otherwise they should be redirected
back to the login page.
</p>
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_6.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="327" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb_2.png" width="530" border="0" />
          </a>
        </p>
        <p>
We first will need two actions, one for displaying the login view and one for processing
the login attempt, which I've provided below:
</p>
        <div>
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #008000">///
&lt;summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #008000">///
Displays the login view (the form to enter credentials)</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #008000">///
&lt;/summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">public</span> ActionResult
Login()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">return</span> View(<span style="color: #006080">"Login"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span>
              <span style="color: #008000">///
&lt;summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span>
              <span style="color: #008000">///
Handles form data from the login view, in other words, the form, which</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span>
              <span style="color: #008000">///
is on "login.aspx" has a form tag with it's action set to "ProcessLogin",</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span>
              <span style="color: #008000">///
the name of this method.</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span>
              <span style="color: #008000">///
&lt;/summary&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span>
              <span style="color: #0000ff">public</span> ActionResult
ProcessLogin(<span style="color: #0000ff">string</span> email, <span style="color: #0000ff">string</span> password)</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span> IUser
user = userRepository.GetByEmail(email);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span>
              <span style="color: #0000ff">if</span> (user
!= <span style="color: #0000ff">null</span> &amp;&amp; authenticator.VerifyAccount(user,
password))</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span> authenticator.SignIn(user);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span>
              <span style="color: #0000ff">return</span> RedirectToAction(<span style="color: #006080">"Index"</span>, <span style="color: #006080">"Account"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span> } </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span>
              <span style="color: #008000">//login
failed</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span>
              <span style="color: #008000">//
add some message here in TempData to tell the user the login failed</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 27:</span>
              <span style="color: #0000ff">return</span> RedirectToAction(<span style="color: #006080">"Login"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 28:</span> }</pre>
          </div>
        </div>
        <div>Notice the different return types in the both of the methods.  Login() has
one exit point, "return View("Login")"  and ProcessLogin
has two exit points both of which use RedirectToAction() call, which instead returns
an objected of RedirectToRouteResult, a subclass of ViewResult.  <strong>To properly
perform PRG you must return a redirecting ViewResult from your action, such as RedirectToRouteResult,
otherwise you'll get the dialog box pictured above</strong>.
</div>
        <div> 
</div>
        <div>Here is the login view (login.aspx).  The important part to pay attention
to is the "action" attribute.
</div>
        <div> 
</div>
        <div>
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">form</span>
              <span style="color: #ff0000">name</span>
              <span style="color: #0000ff">="loginActionForm"</span>
              <span style="color: #ff0000">method</span>
              <span style="color: #0000ff">="post"</span>
              <span style="color: #ff0000">action</span>
              <span style="color: #0000ff">="ProcessLogin"</span>
              <span style="color: #ff0000">id</span>
              <span style="color: #0000ff">="loginActionForm"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">fieldset</span>
              <span style="color: #ff0000">class</span>
              <span style="color: #0000ff">="login"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">legend</span>
              <span style="color: #0000ff">&gt;</span>Login<span style="color: #0000ff">&lt;/</span><span style="color: #800000">legend</span><span style="color: #0000ff">&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">label</span>
              <span style="color: #ff0000">for</span>
              <span style="color: #0000ff">="email"</span>
              <span style="color: #0000ff">&gt;</span>Email<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">input</span>
              <span style="color: #ff0000">type</span>
              <span style="color: #0000ff">="textbox"</span>
              <span style="color: #ff0000">id</span>
              <span style="color: #0000ff">="lemail"</span>
              <span style="color: #ff0000">name</span>
              <span style="color: #0000ff">="email"</span>
              <span style="color: #ff0000">maxlength</span>
              <span style="color: #0000ff">="100"</span>
              <span style="color: #ff0000">value</span>
              <span style="color: #0000ff">=""</span>
              <span style="color: #ff0000">class</span>
              <span style="color: #0000ff">="required"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">label</span>
              <span style="color: #ff0000">for</span>
              <span style="color: #0000ff">="password"</span>
              <span style="color: #0000ff">&gt;</span>Password<span style="color: #0000ff">&lt;/</span><span style="color: #800000">label</span><span style="color: #0000ff">&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">input</span>
              <span style="color: #ff0000">type</span>
              <span style="color: #0000ff">="password"</span>
              <span style="color: #ff0000">id</span>
              <span style="color: #0000ff">="lpassword"</span>
              <span style="color: #ff0000">name</span>
              <span style="color: #0000ff">="password"</span>
              <span style="color: #ff0000">maxlength</span>
              <span style="color: #0000ff">="256"</span>
              <span style="color: #ff0000">class</span>
              <span style="color: #0000ff">="required"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">input</span>
              <span style="color: #ff0000">type</span>
              <span style="color: #0000ff">="image"</span>
              <span style="color: #ff0000">src</span>
              <span style="color: #0000ff">="&lt;%=
AppHelper.ImageUrl("</span>
              <span style="color: #ff0000">btn_go</span>.<span style="color: #ff0000">gif</span><span style="color: #0000ff">")
%&gt;"</span><span style="color: #ff0000">class</span><span style="color: #0000ff">="submit"</span><span style="color: #0000ff">/&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span>
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">div</span>
              <span style="color: #ff0000">class</span>
              <span style="color: #0000ff">="errorlist"</span>
              <span style="color: #0000ff">&gt;&lt;/</span>
              <span style="color: #800000">div</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span>
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">fieldset</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span>
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">form</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
          </div>
        </div>
        <p>
By implementing the PRG pattern, I get nice clean urls that are bookmarkable. 
My users also get a nice site that is traversable and aren't presented with confusing
security dialog messages
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=94fe3fa1-2acf-4e91-a316-d2d8aaf4d010" />
      </body>
      <title>PRG Pattern in the ASP.NET MVC Framework</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,94fe3fa1-2acf-4e91-a316-d2d8aaf4d010.aspx</guid>
      <link>http://www.timbarcz.com/blog/PRGPatternInTheASPNETMVCFramework.aspx</link>
      <pubDate>Fri, 22 Aug 2008 16:40:39 GMT</pubDate>
      <description>&lt;p&gt;
Have you ever been traveling through the &amp;quot;internets&amp;quot; and have been presented
with the following?
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="166" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb.png" width="374" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb_3.png" width="562" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
As web developers we know what this means; a form was posted to the page and now you're
trying to refresh that same page.&amp;#160; I'm not sure if there's been any significant
usability study on the subject but I would imagine my Grandmother wouldn't know what
to do here.&amp;#160; Enter the PRG pattern.
&lt;/p&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;h2&gt;What is the PRG Pattern?
&lt;/h2&gt;
&lt;p&gt;
While the PRG pattern isn't knew, there isn't much out there on it for the .NET community.&amp;#160;
PRG stands for &amp;quot;Post/Redirect/Get&amp;quot;, I'll let Wikipedia explain the rest:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
instead of returning an HTML page directly, the POST operation returns a redirection
command (using the HTTP 303 response code (sometimes 302) together with the HTTP &amp;quot;Location&amp;quot;
response header), instructing the browser to load a different page using an HTTP GET
request. The result page can then safely be bookmarked or reloaded without unexpected
side effects.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
While this could be accomplished in webforms, it would be much more difficult since
the postback model hangs on pages posting to themselves to implement button clicks
and the like.&amp;#160; The MVC Framework on the other hand makes the implementation of
the PRG pattern extremely easy.&amp;#160; 
&lt;/p&gt;
&lt;h2&gt;But How?&amp;#160; Can I See an Example?
&lt;/h2&gt;
&lt;p&gt;
I'm going to use an Login function as an example.&amp;#160; If the login attempt is successful,
the user should be redirected to their account page, otherwise they should be redirected
back to the login page.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="327" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/PRGPatternintheASP.NETMVCFramework_A3C7/image_thumb_2.png" width="530" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
We first will need two actions, one for displaying the login view and one for processing
the login attempt, which I've provided below:
&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
Displays the login view (the form to enter credentials)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ActionResult
Login()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; View(&lt;span style="color: #006080"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
Handles form data from the login view, in other words, the form, which&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
is on &amp;quot;login.aspx&amp;quot; has a form tag with it's action set to &amp;quot;ProcessLogin&amp;quot;,&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
the name of this method.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt; &lt;span style="color: #008000"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ActionResult
ProcessLogin(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; email, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; password)&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; IUser
user = userRepository.GetByEmail(email);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (user
!= &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; authenticator.VerifyAccount(user,
password))&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt; authenticator.SignIn(user);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; RedirectToAction(&lt;span style="color: #006080"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Account&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; } &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt; &lt;span style="color: #008000"&gt;//login
failed&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt; &lt;span style="color: #008000"&gt;//
add some message here in TempData to tell the user the login failed&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 27:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; RedirectToAction(&lt;span style="color: #006080"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 28:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;Notice the different return types in the both of the methods.&amp;#160; Login() has
one exit point, &amp;quot;return View(&amp;quot;Login&amp;quot;)&amp;quot;&amp;#160; and ProcessLogin
has two exit points both of which use RedirectToAction() call, which instead returns
an objected of RedirectToRouteResult, a subclass of ViewResult.&amp;#160; &lt;strong&gt;To properly
perform PRG you must return a redirecting ViewResult from your action, such as RedirectToRouteResult,
otherwise you'll get the dialog box pictured above&lt;/strong&gt;.
&lt;/div&gt;
&lt;div&gt;&amp;#160;
&lt;/div&gt;
&lt;div&gt;Here is the login view (login.aspx).&amp;#160; The important part to pay attention
to is the &amp;quot;action&amp;quot; attribute.
&lt;/div&gt;
&lt;div&gt;&amp;#160;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;loginActionForm&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;method&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;post&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;action&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProcessLogin&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;loginActionForm&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;fieldset&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;login&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;legend&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Login&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;legend&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;label&lt;/span&gt; &lt;span style="color: #ff0000"&gt;for&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;email&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Email&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;label&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;input&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;textbox&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;lemail&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;email&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;maxlength&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;required&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;label&lt;/span&gt; &lt;span style="color: #ff0000"&gt;for&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;password&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Password&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;label&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;input&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;lpassword&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;maxlength&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;256&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;required&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;input&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;image&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;src&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;&amp;lt;%=
AppHelper.ImageUrl(&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt;btn_go&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;gif&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;quot;)
%&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;submit&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;errorlist&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;div&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;fieldset&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;form&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
By implementing the PRG pattern, I get nice clean urls that are bookmarkable.&amp;#160;
My users also get a nice site that is traversable and aren't presented with confusing
security dialog messages
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=94fe3fa1-2acf-4e91-a316-d2d8aaf4d010" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,94fe3fa1-2acf-4e91-a316-d2d8aaf4d010.aspx</comments>
      <category>MVC</category>
      <category>Tips &amp; Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=ed3e7303-ac21-47f3-870d-3606123793f3</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,ed3e7303-ac21-47f3-870d-3606123793f3.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,ed3e7303-ac21-47f3-870d-3606123793f3.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ed3e7303-ac21-47f3-870d-3606123793f3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/StronglyTypedViewDataWithoutACodebehind_D743/image_4.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="341" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/StronglyTypedViewDataWithoutACodebehind_D743/image_thumb_1.png" width="258" align="right" border="0" />
          </a> I'm
not a fan of the codebehind and designer files that are generated when you create
a new ViewPage.  I like a clean solution and for me that means view files (.aspx)
that don't have plusses next to them (see the photo to the right and compare the <strong>Home</strong> and <strong>Login</strong> folders).
</p>
        <p>
If you want to use strongly typed view data and you don't want to add the codebehind
and designer files for the measly few characters you have to type to make a view strongly
typed:
</p>
        <div>
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">partial</span>
              <span style="color: #0000ff">class</span> Index
: ViewPage&lt;LoginData&gt;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> }</pre>
          </div>
        </div>
        <p>
In this particular case I have to add two extra files to source control solely for
the purpose of having "&lt;LoginData&gt;"...seems like a waste.
</p>
        <h2>CLR Notation
</h2>
        <p>
If you want to do the same thing without the extra overhead of two files, simple use
CLR notation
</p>
        <div>
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span> &lt;%@
Page Language=<span style="color: #006080">"C#"</span> MasterPageFile=<span style="color: #006080">"~/Views/Shared/Site.Master"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> CodeBehind=<span style="color: #006080">"Index.aspx.cs"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> Inherits=<span style="color: #006080">"ABCCompany.MVC.Web.Views.Home.Index"</span> %&gt;</pre>
          </div>
        </div>
        <p>
becomes
</p>
        <div>
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span> &lt;%@
Page Language=<span style="color: #006080">"C#"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> MasterPageFile=<span style="color: #006080">"~/Views/Shared/Site.Master"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> Inherits=<span style="color: #006080">"System.Web.Mvc.ViewPage`1[[ABCCompany.MVC.Web.Models.LoginData,
ABCCompany.MVC.Web]]"</span> %&gt;</pre>
          </div>
        </div>
        <p>
Not the prettiest code I've ever seen, but it gets the job done without extra (needless)
files.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=ed3e7303-ac21-47f3-870d-3606123793f3" />
      </body>
      <title>Strongly-Typed ViewData Without A Codebehind</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,ed3e7303-ac21-47f3-870d-3606123793f3.aspx</guid>
      <link>http://www.timbarcz.com/blog/StronglyTypedViewDataWithoutACodebehind.aspx</link>
      <pubDate>Wed, 13 Aug 2008 20:18:31 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/StronglyTypedViewDataWithoutACodebehind_D743/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="341" alt="image" src="http://www.timbarcz.com/blog/content/binary/WindowsLiveWriter/StronglyTypedViewDataWithoutACodebehind_D743/image_thumb_1.png" width="258" align="right" border="0" /&gt;&lt;/a&gt; I'm
not a fan of the codebehind and designer files that are generated when you create
a new ViewPage.&amp;#160; I like a clean solution and for me that means view files (.aspx)
that don't have plusses next to them (see the photo to the right and compare the &lt;strong&gt;Home&lt;/strong&gt; and &lt;strong&gt;Login&lt;/strong&gt; folders).
&lt;/p&gt;
&lt;p&gt;
If you want to use strongly typed view data and you don't want to add the codebehind
and designer files for the measly few characters you have to type to make a view strongly
typed:
&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Index
: ViewPage&amp;lt;LoginData&amp;gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
In this particular case I have to add two extra files to source control solely for
the purpose of having &amp;quot;&amp;lt;LoginData&amp;gt;&amp;quot;...seems like a waste.
&lt;/p&gt;
&lt;h2&gt;CLR Notation
&lt;/h2&gt;
&lt;p&gt;
If you want to do the same thing without the extra overhead of two files, simple use
CLR notation
&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &amp;lt;%@
Page Language=&lt;span style="color: #006080"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; MasterPageFile=&lt;span style="color: #006080"&gt;&amp;quot;~/Views/Shared/Site.Master&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; CodeBehind=&lt;span style="color: #006080"&gt;&amp;quot;Index.aspx.cs&amp;quot;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; Inherits=&lt;span style="color: #006080"&gt;&amp;quot;ABCCompany.MVC.Web.Views.Home.Index&amp;quot;&lt;/span&gt; %&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
becomes
&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &amp;lt;%@
Page Language=&lt;span style="color: #006080"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; MasterPageFile=&lt;span style="color: #006080"&gt;&amp;quot;~/Views/Shared/Site.Master&amp;quot;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; Inherits=&lt;span style="color: #006080"&gt;&amp;quot;System.Web.Mvc.ViewPage`1[[ABCCompany.MVC.Web.Models.LoginData,
ABCCompany.MVC.Web]]&amp;quot;&lt;/span&gt; %&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Not the prettiest code I've ever seen, but it gets the job done without extra (needless)
files.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=ed3e7303-ac21-47f3-870d-3606123793f3" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,ed3e7303-ac21-47f3-870d-3606123793f3.aspx</comments>
      <category>MVC</category>
      <category>Tips &amp; Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=7ba78de9-2bb3-408a-876e-e19f08dda65c</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7ba78de9-2bb3-408a-876e-e19f08dda65c</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is the third in an ongoing series of articles about my team's transition to the <a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx">Asp.NET
MVC Framework</a>.  In my <a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx">last
post</a> I blogged a bit about how I haven't quite got comfortable enough with the
new MVC framework to feel über productive.  What augments the feeling is
the difficulty of finding quality information.  The data is few and far between
and only sometimes relevant.
</p>
        <p>
I was struggling yesterday to find information on the ComponentController class. 
Things I was finding were from the Preview 2 release but finding something on the
Preview 3 release was a bit more challenging.  Things are rapidly changing in
the framework and the MVC team is not afraid to refactor, rename , or even remove
a class.  For example, with the release last night, ComponentController is no
longer a worry of mine because it's now gone, removed completely from the framework.  
</p>
        <p>
The MVC framework has been around for under a year (Nov 2007 I believe).  It
is now in it's fourth iteration (Preview four, released last night).  While a
number of people have downloaded and are using the framework the amount of data/tutorials/blogs/articles
pales in comparison to the same information about web forms.  This makes finding
the info you need much much tougher.  It's exciting though and must say I enjoy
the challenge.  The change in releases doesn't bother me.  It's a bit of
a nuisance but I signed up for this trip.  Also the changes are for the better. 
The ComponentController class that was replaced yesterday was not easily testable. 
The MVC team removed it in favor of the Controller class, which is testable! 
Fundamentally it boils down to the fact that I trust the guys on the MVC team and
where they're going with the framework.
</p>
        <p>
That trust doesn't help me day to day in moving my project forward though.  In
order to find the data I need I've had to be both resourceful and thorough in my reading. 
The trick I've found is following a few bloggers closely and reading all of their
posts regarding MVC and all comments made to the posts (that's where I find the real
gems, in the comments).
</p>
        <p>
Here is a list of bloggers I'm following, obviously some are well-known, others are
not.  <strong>If you follow some bloggers who post about the MVC framework that
aren't on my list please share!!</strong> My list:
</p>
        <ul>
          <li>
            <a href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a>
          </li>
          <li>
            <a href="http://www.haacked.com">Phil Haack</a>
          </li>
          <li>
            <a href="http://www.hansleman.com">Scott Hanselman</a>
          </li>
          <li>
            <a href="http://blog.wekeroad.com/">Rob Conery</a>
          </li>
          <li>
            <a href="http://mhinze.com/">Matt Hinze</a>
          </li>
          <li>
            <a href="http://www.flux88.com">Ben Scheirman</a>
          </li>
          <li>
            <a href="http://blog.eworldui.net/">Matt Hawley</a>
          </li>
        </ul>
        <p>
Updated to add new blogs (7/23/2008) ... thanks Ben
</p>
        <ul>
          <li>
            <a href="http://blog.codeville.net/">Steve Sanderson</a>
          </li>
          <li>
            <a href="http://weblogs.asp.net/stephenwalther/">Stephen Walther</a>
          </li>
        </ul>
        <p>
Yesterday I reported that I was <a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx">learning
to walk</a> and while I can't quite say I'm walking yet,  I'm feeling a bit more
comfortable.  My velocity increased ever so slightly today and I'm encouraged
by that and excited for tomorrow!  And to be quite honest that's a perfectly
find place to be.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7ba78de9-2bb3-408a-876e-e19f08dda65c" />
      </body>
      <title>MVC Framework - A Needle In a Haystack</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</guid>
      <link>http://www.timbarcz.com/blog/MVCFrameworkANeedleInAHaystack.aspx</link>
      <pubDate>Fri, 18 Jul 2008 01:50:11 GMT</pubDate>
      <description>&lt;p&gt;
This is the third in an ongoing series of articles about my team's transition to the &lt;a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx"&gt;Asp.NET
MVC Framework&lt;/a&gt;.&amp;#160; In my &lt;a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx"&gt;last
post&lt;/a&gt; I blogged a bit about how I haven't quite got comfortable enough with the
new MVC framework to feel &amp;#252;ber productive.&amp;#160; What augments the feeling is
the difficulty of finding quality information.&amp;#160; The data is few and far between
and only sometimes relevant.
&lt;/p&gt;
&lt;p&gt;
I was struggling yesterday to find information on the ComponentController class.&amp;#160;
Things I was finding were from the Preview 2 release but finding something on the
Preview 3 release was a bit more challenging.&amp;#160; Things are rapidly changing in
the framework and the MVC team is not afraid to refactor, rename , or even remove
a class.&amp;#160; For example, with the release last night, ComponentController is no
longer a worry of mine because it's now gone, removed completely from the framework.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
The MVC framework has been around for under a year (Nov 2007 I believe).&amp;#160; It
is now in it's fourth iteration (Preview four, released last night).&amp;#160; While a
number of people have downloaded and are using the framework the amount of data/tutorials/blogs/articles
pales in comparison to the same information about web forms.&amp;#160; This makes finding
the info you need much much tougher.&amp;#160; It's exciting though and must say I enjoy
the challenge.&amp;#160; The change in releases doesn't bother me.&amp;#160; It's a bit of
a nuisance but I signed up for this trip.&amp;#160; Also the changes are for the better.&amp;#160;
The ComponentController class that was replaced yesterday was not easily testable.&amp;#160;
The MVC team removed it in favor of the Controller class, which is testable!&amp;#160;
Fundamentally it boils down to the fact that I trust the guys on the MVC team and
where they're going with the framework.
&lt;/p&gt;
&lt;p&gt;
That trust doesn't help me day to day in moving my project forward though.&amp;#160; In
order to find the data I need I've had to be both resourceful and thorough in my reading.&amp;#160;
The trick I've found is following a few bloggers closely and reading all of their
posts regarding MVC and all comments made to the posts (that's where I find the real
gems, in the comments).
&lt;/p&gt;
&lt;p&gt;
Here is a list of bloggers I'm following, obviously some are well-known, others are
not.&amp;#160; &lt;strong&gt;If you follow some bloggers who post about the MVC framework that
aren't on my list please share!!&lt;/strong&gt; My list:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.haacked.com"&gt;Phil Haack&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.hansleman.com"&gt;Scott Hanselman&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blog.wekeroad.com/"&gt;Rob Conery&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://mhinze.com/"&gt;Matt Hinze&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.flux88.com"&gt;Ben Scheirman&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blog.eworldui.net/"&gt;Matt Hawley&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Updated to add new blogs (7/23/2008) ... thanks Ben
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://blog.codeville.net/"&gt;Steve Sanderson&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://weblogs.asp.net/stephenwalther/"&gt;Stephen Walther&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Yesterday I reported that I was &lt;a href="http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx"&gt;learning
to walk&lt;/a&gt; and while I can't quite say I'm walking yet,&amp;#160; I'm feeling a bit more
comfortable.&amp;#160; My velocity increased ever so slightly today and I'm encouraged
by that and excited for tomorrow!&amp;#160; And to be quite honest that's a perfectly
find place to be.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=7ba78de9-2bb3-408a-876e-e19f08dda65c" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,7ba78de9-2bb3-408a-876e-e19f08dda65c.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=e22cc57d-a5d3-4265-87b8-554d9796618a</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e22cc57d-a5d3-4265-87b8-554d9796618a</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <img src="http://farm2.static.flickr.com/1382/959864706_894bdfaa56.jpg?v=0" align="right" />A
few days ago I posted that our team was making the <a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx">transition
from webforms to MVC</a>.  Since then a few days have gone by and I wanted to
post my some struggles and successes (however few) in recent days. 
<p>
First, it's been tough wrapping my head around the shift from web forms to MVC. 
I would caution anyone making a similar shift or considering it, that despite the
recognized short comings of web forms and the postback model that one should approach
the change expecting a bit of a rough going in the beginning.  Never underestimate
what years of articles, blogs, and webcasts about web forms and working in web forms
will do to your perspective.  OnClick...gone.  PreRender...gone.
</p><p>
Does the experience thus far cause me to regret the choice to go MVC route? 
Absolutely not.  It was 100% the correct decision.  Despite the difficulties
of making the shift, there are points where something clicks and it feels better and
more natural.  I'm waiting for that shift and those clicks to be more permanent. 
The best analogy I can use to explain it is likening the experience to my one year
old son who is learning to walk. To him crawling feels right.  When crawling,
he's quicker, self-assured, and can generally get where he wants to go.  When
he attempts to walk however, he falls down, he struggles to keep his balance, and
generally getting anywhere takes longer.  It's temporary though, we know it and
that's why we encourage him to walk and push through the awkwardness. In a few years
Lincoln will realize (if not verbally but by the way he chooses to move) how much
more natural walking is than crawling, a fact that I'm reminded of every time I get
down on all fours with Lincoln.
</p><p>
So what am I doing to push through?  First I'm trying to keep in the project. 
With smaller tasks and projects always requiring attention, I'm trying to stay in
the project as much as possible.  Secondly, I'm thinking about how I think (<a href="http://en.wikipedia.org/wiki/Metacognition">Metacognition</a>). 
Thinking about MVC, testability, loose coupling and other such principles only aid
in the transition.  I'm hoping the next two days this week give way to breakthroughs. 
Near the end of the day I had some small wins and started to gain some velocity which
leaves me optimistic for tomorrow.
</p><img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=e22cc57d-a5d3-4265-87b8-554d9796618a" /></body>
      <title>MVC Framework - Learning to Walk</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</guid>
      <link>http://www.timbarcz.com/blog/MVCFrameworkLearningToWalk.aspx</link>
      <pubDate>Thu, 17 Jul 2008 01:27:19 GMT</pubDate>
      <description>&lt;img src="http://farm2.static.flickr.com/1382/959864706_894bdfaa56.jpg?v=0" align="right" /&gt;A
few days ago I posted that our team was making the &lt;a href="http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx"&gt;transition
from webforms to MVC&lt;/a&gt;.&amp;#160; Since then a few days have gone by and I wanted to
post my some struggles and successes (however few) in recent days. 
&lt;p&gt;
First, it's been tough wrapping my head around the shift from web forms to MVC.&amp;#160;
I would caution anyone making a similar shift or considering it, that despite the
recognized short comings of web forms and the postback model that one should approach
the change expecting a bit of a rough going in the beginning.&amp;#160; Never underestimate
what years of articles, blogs, and webcasts about web forms and working in web forms
will do to your perspective.&amp;#160; OnClick...gone.&amp;#160; PreRender...gone.
&lt;/p&gt;
&lt;p&gt;
Does the experience thus far cause me to regret the choice to go MVC route?&amp;#160;
Absolutely not.&amp;#160; It was 100% the correct decision.&amp;#160; Despite the difficulties
of making the shift, there are points where something clicks and it feels better and
more natural.&amp;#160; I'm waiting for that shift and those clicks to be more permanent.&amp;#160;
The best analogy I can use to explain it is likening the experience to my one year
old son who is learning to walk. To him crawling feels right.&amp;#160; When crawling,
he's quicker, self-assured, and can generally get where he wants to go.&amp;#160; When
he attempts to walk however, he falls down, he struggles to keep his balance, and
generally getting anywhere takes longer.&amp;#160; It's temporary though, we know it and
that's why we encourage him to walk and push through the awkwardness. In a few years
Lincoln will realize (if not verbally but by the way he chooses to move) how much
more natural walking is than crawling, a fact that I'm reminded of every time I get
down on all fours with Lincoln.
&lt;/p&gt;
&lt;p&gt;
So what am I doing to push through?&amp;#160; First I'm trying to keep in the project.&amp;#160;
With smaller tasks and projects always requiring attention, I'm trying to stay in
the project as much as possible.&amp;#160; Secondly, I'm thinking about how I think (&lt;a href="http://en.wikipedia.org/wiki/Metacognition"&gt;Metacognition&lt;/a&gt;).&amp;#160;
Thinking about MVC, testability, loose coupling and other such principles only aid
in the transition.&amp;#160; I'm hoping the next two days this week give way to breakthroughs.&amp;#160;
Near the end of the day I had some small wins and started to gain some velocity which
leaves me optimistic for tomorrow.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=e22cc57d-a5d3-4265-87b8-554d9796618a" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,e22cc57d-a5d3-4265-87b8-554d9796618a.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
    </item>
    <item>
      <trackback:ping>http://www.timbarcz.com/blog/Trackback.aspx?guid=96028e7e-ac48-4277-ba74-4d2602ae7989</trackback:ping>
      <pingback:server>http://www.timbarcz.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.timbarcz.com/blog/PermaLink,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</pingback:target>
      <dc:creator>Tim Barcz</dc:creator>
      <wfw:comment>http://www.timbarcz.com/blog/CommentView,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</wfw:comment>
      <wfw:commentRss>http://www.timbarcz.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=96028e7e-ac48-4277-ba74-4d2602ae7989</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We recently decided that with the effort we're putting into <a href="http://www.jpcycles.com">our
website</a> and some changes that we're making that now would be as good of time as
ever to make the switch to the new <a href="http://www.asp.net/mvc">Asp.net MVC Framework</a>. 
We're no Google, but we're currently receiving around 18,000 unique visitors a day
and 300,000 page views and hope to grow that number as we make our site easier to
use for our customers.  I hope to rely heavily on <a href="http://www.haacked.com">Phil</a>, <a href="http://blog.wekeroad.com">Rob</a>,
and <a href="http://www.hanselman.com">Scott</a> for assistance if needed.  
</p>
        <p>
The MVC design appeals to us because the large amount of business logic that has crept
it's way into the codebehind.  Despite the best intentions, the current site,
which is programmed in asp.net 1.1, has had too much logic to creep into presentational
areas while running with webforms.  The biggest drawback to this is reduced testability. 
Testability should be important in any project but for us it is paramount. We have
business rules that if not adhered to amount to real-world fines:
</p>
        <blockquote>
          <p>
A few years ago a customer bought some lubricant that is sold in an aerosol can. 
Since 9/11 aerosol cans cannot be shipped as cargo on airplanes.  Somehow this
order made it though the checks we have for this type of thing in the warehouse and
made it onto the UPS truck.  At the UPS facility, a UPS employee heard something
emanating from a box that sounded like an aerosol can.  At that point he is required
by law to check the contents.  When he opened the box he found the aerosol cans. 
Despite knowing us and our reputation, he was required to call the FAA and say something
to the effect of, "I found some aerosol cans in a package that was scheduled
to be flown."  It didn't matter that this was an accident or "just
a few cans", we were still fined.  We were warned that if this were to happen
again that we would face a fine somewhere in the low six figures. The FAA doesn't
mess around.
</p>
        </blockquote>
        <p>
As we go forward I plan to document on this blog the highs and lows of our transition. 
I'll post questions and problems we're having that I hope you can help with as well
as tips and tricks our team has found helpful.  Stay tuned as we make the transition.
</p>
        <img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=96028e7e-ac48-4277-ba74-4d2602ae7989" />
      </body>
      <title>Using MVC Framework In the Wild, Our Transition to the ASP.NET MVC Framework</title>
      <guid isPermaLink="false">http://www.timbarcz.com/blog/PermaLink,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</guid>
      <link>http://www.timbarcz.com/blog/UsingMVCFrameworkInTheWildOurTransitionToTheASPNETMVCFramework.aspx</link>
      <pubDate>Mon, 14 Jul 2008 15:51:29 GMT</pubDate>
      <description>&lt;p&gt;
We recently decided that with the effort we're putting into &lt;a href="http://www.jpcycles.com"&gt;our
website&lt;/a&gt; and some changes that we're making that now would be as good of time as
ever to make the switch to the new &lt;a href="http://www.asp.net/mvc"&gt;Asp.net MVC Framework&lt;/a&gt;.&amp;#160;
We're no Google, but we're currently receiving around 18,000 unique visitors a day
and 300,000 page views and hope to grow that number as we make our site easier to
use for our customers.&amp;#160; I hope to rely heavily on &lt;a href="http://www.haacked.com"&gt;Phil&lt;/a&gt;, &lt;a href="http://blog.wekeroad.com"&gt;Rob&lt;/a&gt;,
and &lt;a href="http://www.hanselman.com"&gt;Scott&lt;/a&gt; for assistance if needed.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
The MVC design appeals to us because the large amount of business logic that has crept
it's way into the codebehind.&amp;#160; Despite the best intentions, the current site,
which is programmed in asp.net 1.1, has had too much logic to creep into presentational
areas while running with webforms.&amp;#160; The biggest drawback to this is reduced testability.&amp;#160;
Testability should be important in any project but for us it is paramount. We have
business rules that if not adhered to amount to real-world fines:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
A few years ago a customer bought some lubricant that is sold in an aerosol can.&amp;#160;
Since 9/11 aerosol cans cannot be shipped as cargo on airplanes.&amp;#160; Somehow this
order made it though the checks we have for this type of thing in the warehouse and
made it onto the UPS truck.&amp;#160; At the UPS facility, a UPS employee heard something
emanating from a box that sounded like an aerosol can.&amp;#160; At that point he is required
by law to check the contents.&amp;#160; When he opened the box he found the aerosol cans.&amp;#160;
Despite knowing us and our reputation, he was required to call the FAA and say something
to the effect of, &amp;quot;I found some aerosol cans in a package that was scheduled
to be flown.&amp;quot;&amp;#160; It didn't matter that this was an accident or &amp;quot;just
a few cans&amp;quot;, we were still fined.&amp;#160; We were warned that if this were to happen
again that we would face a fine somewhere in the low six figures. The FAA doesn't
mess around.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
As we go forward I plan to document on this blog the highs and lows of our transition.&amp;#160;
I'll post questions and problems we're having that I hope you can help with as well
as tips and tricks our team has found helpful.&amp;#160; Stay tuned as we make the transition.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.timbarcz.com/blog/aggbug.ashx?id=96028e7e-ac48-4277-ba74-4d2602ae7989" /&gt;</description>
      <comments>http://www.timbarcz.com/blog/CommentView,guid,96028e7e-ac48-4277-ba74-4d2602ae7989.aspx</comments>
      <category>.NET</category>
      <category>MVC</category>
      <category>Software</category>
    </item>
  </channel>
</rss>