<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0">
  <channel>
    <title>Shane Bauer Blog</title>
    <description>.NET, ASP.NET and Software Development</description>
    <link>http://www.shanebauer.com/blog/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.Net Syndication Generator 1.0.0.0 (http://dotnetblogengine.net/)</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://www.shanebauer.com/blog/opml.axd</blogChannel:blogRoll>
    <dc:creator>My name</dc:creator>
    <dc:title>Shane Bauer Blog</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/sbauer" type="application/rss+xml" /><item>
      <title>Upgrading to Ruby 1.9.1 for Windows</title>
      <description>&lt;p&gt;
I spent some time upgrading to Ruby 1.9.1 not too long ago. For Ruby/Rails devs using Windows (I know there a few of you closet developers out there), if you&amp;#39;re using the 1.9.1 preview binary, you need to add the DLL dependencies yourself. For some unknown reason, they did not package the required DLLs with the package. If you have 1.8.7 installed, you can copy the DLLs from that install&amp;#39;s bin directory and place them into your Ruby 1.9.1 bin directory. Here&amp;#39;s the list below. Note the change in file names for the zlib directory.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
[Ruby 1.8.7]\bin\libeay32.dll -&amp;gt; [Ruby 1.9.1]\bin\libeay32.dll&lt;br /&gt;
[Ruby 1.8.7]\bin\readline.dll -&amp;gt; [Ruby 1.9.1]\bin\readline.dll&lt;br /&gt;
[Ruby 1.8.7]\bin\ssleay32.dll -&amp;gt; [Ruby 1.9.1]\bin\ssleay32.dll&lt;br /&gt;
[Ruby 1.8.7]\bin\&lt;strong&gt;zlib1&lt;/strong&gt;.dll -&amp;gt; [Ruby 1.9.1]\bin\&lt;strong&gt;zlib&lt;/strong&gt;.dll
&lt;/p&gt;
&lt;p&gt;
I know Ruby/Rails wasn&amp;#39;t designed with Windows in-mind, but if you&amp;#39;re going to make it available, at least package the dependencies for it. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ot3jMs9vbiA:qc566aQ6wXk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ot3jMs9vbiA:qc566aQ6wXk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=ot3jMs9vbiA:qc566aQ6wXk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ot3jMs9vbiA:qc566aQ6wXk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ot3jMs9vbiA:qc566aQ6wXk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=ot3jMs9vbiA:qc566aQ6wXk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ot3jMs9vbiA:qc566aQ6wXk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2009/02/Upgrading-to-Ruby-191-for-Windows.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2009/02/Upgrading-to-Ruby-191-for-Windows.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=c73e49a1-df31-4050-9593-2e3758eed1ed</guid>
      <pubDate>Mon, 09 Feb 2009 13:04:00 -0500</pubDate>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=c73e49a1-df31-4050-9593-2e3758eed1ed</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=c73e49a1-df31-4050-9593-2e3758eed1ed</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2009/02/Upgrading-to-Ruby-191-for-Windows.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=c73e49a1-df31-4050-9593-2e3758eed1ed</wfw:commentRss>
    </item>
    <item>
      <title>WebForms are great. Try harder</title>
      <description>&lt;p&gt;
I rarely write a post just to link to another blog. Today, though, I&amp;#39;m going to make an exception. 
&lt;/p&gt;
&lt;p&gt;
It&amp;#39;s one thing to ask a question because you don&amp;#39;t get the point, or you just honestly don&amp;#39;t understand something. That&amp;#39;s how you learn. If you don&amp;#39;t ask questions, or research for answers, how are you going to improve? However, it&amp;#39;s a completely different story when you don&amp;#39;t get the point or completely understand, and then create a post telling people that they&amp;#39;re just lazy for not sharing your ignorant view.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Take this post - &lt;a href="http://ra-ajax.org/mythbusters-busting-the-myths-about-webcontrols.blog" target="_blank"&gt;http://ra-ajax.org/mythbusters-busting-the-myths-about-webcontrols.blog&lt;/a&gt; . Basically, his post states that all the problems you&amp;#39;ve had with WebForms are your fault because you didn&amp;#39;t try to understand the implementation better. If you don&amp;#39;t like code-behind files, or ViewState, you would be on his interview &amp;quot;black list&amp;quot;. If you think about it, that black list may be a pretty good list of developers.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
- 1) Having one form for the entire page isn&amp;#39;t just challenging. It&amp;#39;s downright awkward. The setup basically asks you to put your form tag in your master page so that it spans the entire body of the page.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
- 2) You&amp;#39;re talking about anti-design, but you&amp;#39;re complaing about a textbox control? That&amp;#39;s it? Out of everything else there you&amp;#39;re complaining about a textbox control?&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
- 3) IDs get very long. The developer has zero control over the IDs. If you need an ID for any reason, it makes it more difficult than it has to be. I&amp;#39;m tired of having to reference clientid all over the place. To be honest, I&amp;#39;d rather not use your software to solve the problem. I&amp;#39;d rather just use jQuery like everyone else.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Oh no, Thomas, we know what the problems are. We understand the problems pretty well too. To be honest, I&amp;#39;m glad I&amp;#39;m on your black list. I can&amp;#39;t say I&amp;#39;m all that surprised considering his open source project utilizes WebForms. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SFR_uZmLvWw:-MwrQ4j2a3k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SFR_uZmLvWw:-MwrQ4j2a3k:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=SFR_uZmLvWw:-MwrQ4j2a3k:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SFR_uZmLvWw:-MwrQ4j2a3k:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SFR_uZmLvWw:-MwrQ4j2a3k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=SFR_uZmLvWw:-MwrQ4j2a3k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SFR_uZmLvWw:-MwrQ4j2a3k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2009/01/WebForms-are-great-Try-harder.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2009/01/WebForms-are-great-Try-harder.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=878ac26f-6e70-4681-ad25-7c433e46f025</guid>
      <pubDate>Fri, 16 Jan 2009 13:08:00 -0500</pubDate>
      <category>.NET</category>
      <category>.Software Development</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=878ac26f-6e70-4681-ad25-7c433e46f025</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=878ac26f-6e70-4681-ad25-7c433e46f025</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2009/01/WebForms-are-great-Try-harder.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=878ac26f-6e70-4681-ad25-7c433e46f025</wfw:commentRss>
    </item>
    <item>
      <title>Subversion, TeamCity, and Rake = Wow</title>
      <description>&lt;p&gt;
Whenever I start a new project there are certain things that I always need to do. I need to setup the source code repository, create a basic project structure, create a build script to build the project, and setup the project on a build server. 
&lt;/p&gt;
&lt;p&gt;
A few months ago I realized just how much I hated doing all of this. Setting up the repository was the easiest part. I&amp;#39;ve been using Subversion for years. Instead of hosting my own subversion server, I use a &lt;a href="http://www.svnrepository.com/" target="_blank"&gt;third party&lt;/a&gt;. I&amp;#39;ll let them manage the server, subversion upgrades and the backups. Because of this, setting up the repository was basically logging into a control panel, filling out a form, and that&amp;#39;s basically it. However, after this was completed, the tasks became much more redundent.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
For the longest time I used NAnt for my build engine. It is a good tool, no doubt. The problem is I hate XML. I hate it. It&amp;#39;s not the language itself really. It&amp;#39;s how people use XML. NAnt uses XML as the way to write the build script. I hated creating the scripts and I hated modifying them.
&lt;/p&gt;
&lt;p&gt;
Of course, my XML troubles didn&amp;#39;t end there. I used CruiseControl.net as my CI (build) server. The application itself is OK. It&amp;#39;s not great and has aged quite a bit. By far my biggest problem with CC.NET is the process of adding a new project. In order to add a new project to CC.NET, you must modify an XML file. If you have many projects configured, that file may be quite large. 
&lt;/p&gt;
&lt;p&gt;
I don&amp;#39;t know about you, but after setting up my build script and setting up the project in CC.NET, I&amp;#39;m pretty tired of looking at XML. 
&lt;/p&gt;
&lt;h3&gt;Taking a look at TeamCity &lt;/h3&gt;
&lt;p&gt;
After reading a ton of blogs and twitter messages from people talking about &lt;a href="http://www.jetbrains.com/teamcity/index.html" target="_blank"&gt;TeamCity&lt;/a&gt;, I decided to give it a shot. I wasn&amp;#39;t really sure what to expect. I thought it would be good as I&amp;#39;m a huge ReSharper fan (the same company that makes ReSharper also makes TeamCity), but didn&amp;#39;t really know if it would fit my needs.
&lt;/p&gt;
&lt;p&gt;
Fortunately, &lt;a href="http://www.jetbrains.com" target="_blank"&gt;JetBrains&lt;/a&gt; (makers of TeamCity) markets a version of TeamCity targeted for smaller teams that doesn&amp;#39;t cost a thing. I grabbed it, installed it on a VM, and played around. To make a long story short, I&amp;#39;m still using it. TeamCity is a really nice CI server. It&amp;#39;s very extensible and configuration is a breeze. You can add projects and build configurations straight from the browse. No need to modify XML files. TeamCity supports a number of different version control systems and build environments out-of-the-box. NAnt, MSBuild, Ant, and command-line are just a few. Because of this I was able to migrate my project from CC.NET to TeamCity in no time.&amp;nbsp;
&lt;/p&gt;
&lt;h3&gt;Replacing NAnt with Rake &lt;/h3&gt;
&lt;p&gt;
After deciding to go with TeamCity, I felt pretty good. I had solved one problem. I cannot tell you how much time I&amp;#39;ve saved because of it. After a while, though, I started to look for replacement options for NAnt. Like I said before, I like NAnt, but I wanted something better than XML. After doing some research, I decided to look into Rake, a build tool programmed in Ruby. I noticed a few .NET developers using Rake successfully. One evening I loaded my NAnt build script and replicated the entire script using Rake. I&amp;#39;ve done some work in Ruby so it didn&amp;#39;t take that long to convert everything over. Obviously, you don&amp;#39;t have the pre-made nant tasks, but creating a reusable framework that calls the executables for various tools (msbuild, nant) wasn&amp;#39;t too bad. After I got it working locally, I modified my existing build configuration in TeamCity to call the new rake script. Initially, I used the rake runner in TeamCity. After a while, I wasn&amp;#39;t getting the results that I wanted so I switched to the simple command-line runner. After tweaking a few minor things, I was done.&amp;nbsp;
&lt;/p&gt;
&lt;h3&gt;Looking Back &lt;/h3&gt;
&lt;p&gt;
I&amp;#39;m really satisifed how things turned out. TeamCity is a joy to work with. Managing Rake build scripts instead of XML files just feels right. If you&amp;#39;re looking for a replacement or you&amp;#39;re just getting into this territory, you should really take a look at TeamCity and Rake. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=09Bg_Ncbyzo:PVZCSzxZQdA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=09Bg_Ncbyzo:PVZCSzxZQdA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=09Bg_Ncbyzo:PVZCSzxZQdA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=09Bg_Ncbyzo:PVZCSzxZQdA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=09Bg_Ncbyzo:PVZCSzxZQdA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=09Bg_Ncbyzo:PVZCSzxZQdA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=09Bg_Ncbyzo:PVZCSzxZQdA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/10/Subversion2c-TeamCity2c-and-Rake-3d-Wow.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/10/Subversion2c-TeamCity2c-and-Rake-3d-Wow.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=7459bf31-189f-4e03-9ca1-bed67fc781f7</guid>
      <pubDate>Tue, 28 Oct 2008 15:31:00 -0500</pubDate>
      <category>.NET</category>
      <category>.Software Development</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=7459bf31-189f-4e03-9ca1-bed67fc781f7</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=7459bf31-189f-4e03-9ca1-bed67fc781f7</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/10/Subversion2c-TeamCity2c-and-Rake-3d-Wow.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=7459bf31-189f-4e03-9ca1-bed67fc781f7</wfw:commentRss>
    </item>
    <item>
      <title>Customer Service and How Manning Publications Let Me Down</title>
      <description>&lt;p&gt;
I&amp;#39;m a fan of NHibernate. I&amp;#39;ve been using it for a little while and have grown to like it. Last year I found out that an NHibernate book was in the works from Manning. Being a huge fan of NHibernate and Manning, I decided to purchase this book from the &amp;quot;Manning Early Access Program&amp;quot;. Basically, MEAP is a program they setup that gives customers early access to the chapters before they are published. You can either buy the MEAP e-book or the e-book and the print book. Obviously, the print book would be mailed to you once the book is published. The MEAP e-book and print option is usually just a little more expensive (~$5) than a print copy that you would buy in the store. Anyway, I purchased the e-book and print option in June of 2007. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;All Is Well&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
After I purchased the book, a download link was sent to me pretty quickly. I downloaded the available chapters of the book and was pretty satisified. The MEAP program was pretty cool. I could read the book and then give feedback in the forum. Not a bad idea.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Delays and Moving &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
As time progressed I noticed the book kept getting pushed back. Not a big deal to me since I had most of the chapters, but I noticed I was quickly approaching my move date. Finally, in January of 2008, the time had come to move.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Customer Support, Please&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
A month after moving, I remembered I had this book order floating out there.&amp;nbsp; Before I forgot about it, I went to Manning&amp;#39;s site to see if I could change my address. Since I didn&amp;#39;t find any such tool, I found their customer support section and sent an e-mail. This was on &lt;strong&gt;Feb 24th&lt;/strong&gt;. On &lt;strong&gt;March 4th&lt;/strong&gt;, I still did not receive a reply. I sent another e-mail reminding them that I needed to get this change as I won&amp;#39;t be able to get to the old address. After this e-mail I waited quite some time and didn&amp;#39;t receive a response. This time, however, I didn&amp;#39;t sent another e-mail. I went to the site again and found their customer support number. I dialed the number and ended up listening to their voice messaging system. I left a message with my name, number and issue.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Still Need That Support&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I, again, waited some more. By now, we&amp;#39;re in April and I still haven&amp;#39;t heard from a single person there. No e-mail, no phone call, no voicemail on my end. Nothing.&amp;nbsp; Now I&amp;#39;m a little bitter. I sent another e-mail saying basically the same thing, with the added bonus of saying how many times I&amp;#39;ve tried contacting this company. I also copied the customer support manager (I think that&amp;#39;s his title) on it as well. This was sent on &lt;strong&gt;April 17th&lt;/strong&gt;. Can you guess what happened next? If you guessed &amp;quot;No response&amp;quot;, you&amp;#39;re right! Good job! You win half of a Manning book. Now, I challenge you to contact them for the rest. Good luck. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Seriously, though, Support? Please?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
As of last week, I was still without support. Meanwhile, I&amp;#39;ve contacted the author. He told me that he forwarded my request to his contact. Another author also forwarded my request to his editor. Nothing. In my head I&amp;#39;m thinking, &amp;quot;Now what?&amp;quot;. Well, I just did everything all over again. I left another voicemail. I sent another e-mail. This time, though, I copied every e-mail address on the site. I copied the webmaster, the support department, the support manager, and the infringement department. I even forwarded the e-mail to the support manager&amp;#39;s personal e-mail address that he lists on the site. (I&amp;#39;ll get into this more later) This was was on April 25th. Yeah, not too long ago, but still a few business days. Guess what? Yup, nothing.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;A Little Research&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
As of today, April 29th, I&amp;#39;m still in the exact place I was when I started this adventure two months ago. Because of this, though, I&amp;#39;ve spent some time researching other situations. Apparently, I&amp;#39;m &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=59601&amp;amp;#59601" target="_blank"&gt;not&lt;/a&gt; &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=62973&amp;amp;#62973" target="_blank"&gt;the&lt;/a&gt; &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=62746&amp;amp;#62746" target="_blank"&gt;only&lt;/a&gt; &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=52661&amp;amp;#52661" target="_blank"&gt;one&lt;/a&gt; &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=51916" target="_blank"&gt;to&lt;/a&gt; &lt;a href="http://www.manning-sandbox.com/thread.jspa?messageID=53650" target="_blank"&gt;have&lt;/a&gt; this issue. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Excuses, Excuses, Excuses&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If you read their customer support section, you&amp;#39;ll notice that they a blurb about their e-mail support. They say that if you don&amp;#39;t receive a response from them in a few days, e-mail someone else or call the number. The excuse they&amp;#39;re using is &amp;quot;spam filtering&amp;quot;. The support manager even put his own gmail account on the site so people could e-mail that to get around the filtering. I sent a copy of the e-mail to that address as well. No response. I pointed out several examples of customers not getting e-mails. Is the spam filter blocking every e-mail? If it was, don&amp;#39;t you think it would make sense to maybe get a new spam filter or stop using one? Or if that&amp;#39;s so impossible, maybe they should just get rid of e-mail support and ask people to call instead. Oh, that&amp;#39;s right, though. They don&amp;#39;t call back either. They probably didn&amp;#39;t get my messages. The spam filter must block those too.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;In Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;ve learned quite a few things from this experience.
&lt;/p&gt;
&lt;p&gt;
- EAP is a good idea.&lt;br /&gt;
- Their customer support is a joke.&lt;br /&gt;
- It&amp;#39;s unlikely that I&amp;#39;ll buy another Manning book. There are a few EAP books that I like (DSL, Art of Unit Testing, ASP.NET MVC), but as it stands right now, I will not be buying them. I&amp;#39;m not going to spend $50 on a product when I can&amp;#39;t even get recognized by the company.&lt;br /&gt;
- They have some good books, but...&lt;br /&gt;
- Their customer support is a joke.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The Numbers&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Total E-mails Sent: 6&lt;br /&gt;
Total Phone Calls: Countless&lt;br /&gt;
Total Voice messages left: 2 &lt;br /&gt;
Total Sandbox Forum Posts: 1&lt;br /&gt;
Number of e-mails/calls/voice mails received: 0
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Update 4/29/2008 - 3:04pm&lt;/strong&gt;: Just sent two new e-mails: one to an alternate e-mail found on the site, and an e-mail to two other Manning contacts. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=5CAzom2qzbM:CYAWH-kPOMg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=5CAzom2qzbM:CYAWH-kPOMg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=5CAzom2qzbM:CYAWH-kPOMg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=5CAzom2qzbM:CYAWH-kPOMg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=5CAzom2qzbM:CYAWH-kPOMg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=5CAzom2qzbM:CYAWH-kPOMg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=5CAzom2qzbM:CYAWH-kPOMg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/Customer-Service-and-How-Manning-Publications-Let-Me-Down.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/Customer-Service-and-How-Manning-Publications-Let-Me-Down.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=3c7661a1-034c-4ee6-814a-e30525e2b1f8</guid>
      <pubDate>Tue, 29 Apr 2008 10:21:00 -0500</pubDate>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=3c7661a1-034c-4ee6-814a-e30525e2b1f8</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=3c7661a1-034c-4ee6-814a-e30525e2b1f8</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/Customer-Service-and-How-Manning-Publications-Let-Me-Down.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=3c7661a1-034c-4ee6-814a-e30525e2b1f8</wfw:commentRss>
    </item>
    <item>
      <title>Tip: Register Windsor Dependencies via Code, instead of XML</title>
      <description>&lt;p&gt;
One thing I never really liked is component registration via XML. If you were to remove a class, and forgot to remove the class from your configuration, you would find out at runtime. I&amp;#39;d much rather find out at build time and get the benefits from the refactoring tools. 
&lt;/p&gt;
&lt;p&gt;
You can do this by registering your components in code. Typically, you would register your components during application startup. 
&lt;/p&gt;
&lt;p&gt;
container.AddComponent&amp;lt;IPlayerService, PlayerService&amp;gt;();&lt;br /&gt;
container.AddComponent&amp;lt;IBallparkService, BallparkService&amp;gt;();
&lt;/p&gt;
&lt;p&gt;
You have several different options when adding components. In my example, I&amp;#39;m just specifying a service (the interface) and the concrete class (BallParkService) that will be used. When my application needs a IBallParkService, Windsor will pass along the BallparkService. Since I didn&amp;#39;t specify a lifestyle, the default transient lifestyle will be used. The transient lifestyle will create a new instance for every call. &lt;a href="http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInjectionWithCastleWindsorContainerPart4.aspx" target="_blank"&gt;There are other options, though, that you can use depending on your needs.&lt;/a&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=y2uzZnHKTnA:2SbBJHhJkKs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=y2uzZnHKTnA:2SbBJHhJkKs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=y2uzZnHKTnA:2SbBJHhJkKs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=y2uzZnHKTnA:2SbBJHhJkKs:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=y2uzZnHKTnA:2SbBJHhJkKs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=y2uzZnHKTnA:2SbBJHhJkKs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=y2uzZnHKTnA:2SbBJHhJkKs:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/Tip-Register-Windsor-Dependencies-via-Code2c-instead-of-XML.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/Tip-Register-Windsor-Dependencies-via-Code2c-instead-of-XML.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=82a49dcb-3aee-4136-b938-2dc114972888</guid>
      <pubDate>Fri, 25 Apr 2008 15:32:00 -0500</pubDate>
      <category>.NET</category>
      <category>.Software Development</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=82a49dcb-3aee-4136-b938-2dc114972888</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=82a49dcb-3aee-4136-b938-2dc114972888</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/Tip-Register-Windsor-Dependencies-via-Code2c-instead-of-XML.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=82a49dcb-3aee-4136-b938-2dc114972888</wfw:commentRss>
    </item>
    <item>
      <title>Learning MVC is not hard; Learning how to use it correctly is</title>
      <description>&lt;p&gt;
I was browsing the MVC forum on the ASP.NET site and found a topic asking about MVC training. Since the Microsoft ASP.NET MVC framework has not been released yet, you would be hard pressed to find a training class dedicated toward their framework. MVC is not new, though. There are other classes out there that may not target an actual implementation or they&amp;#39;ll target existing implementations (MonoRail, Spring, Structs).
&lt;/p&gt;
&lt;p&gt;
Beyond that, though, I found this post pretty interesting:
&lt;/p&gt;
&lt;blockquote&gt;
	&lt;p&gt;
	&lt;em&gt;&amp;nbsp;in my opinion it&amp;acute;s not so complex as ASP.NET WebForms (because no ViewState and no Postback - its just a ping pong with the view and the controller ;) (and the model ;) )). &lt;/em&gt;
	&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
He&amp;#39;s right. ASP.NET MVC does not have such complex areas as ViewState. You just write a controller, write a method that becomes an action, create and edit your view, and then hook them up. Pretty simple, right? Maybe.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;ASP.NET WebForms - What was the goal?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The WebForms project model tries hard to be developer friendly. It takes HTTP and tries to tuck it away. Instead of worrying about a stateless envrionment, WebForms makes the developer believe that it is quite stateful. ViewState, for example, can help you store state. Even the controls that render simple HTML can remember their values. WebForms, in a basic view, is Windows Forms for the web. You have state, controls and even an event lifecycle for a page. Theoretically, Windows Forms developers should be able to migrate to web projects and see some familiar areas. All is good in the world.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;WebForms Can Be Sneaky&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
After a while, though, that great feeling starts to go away for many developers. ViewState becomes awkward. The controls don&amp;#39;t generate the HTML that I want it to. I can&amp;#39;t seem to test my pages in a non-awkward way. In the end, the WebForms abstraction has become more complicated than the entity that was being hidden. For some developers, the WebForms model works. If it works for you, then great, continue to use it. If not, Microsoft has heard your call.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Welcome, ASP.NET MVC&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
First off, MVC is not some new thing Microsoft invented. Yes, they created their own MVC framework, but they didn&amp;#39;t create the concept. ASP.NET MVC isn&amp;#39;t even the first framework for .NET. MonoRail, another MVC .NET implementation, has been around for quite some time.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The MVC pattern separates the application into three layers: model, view, and controller.&amp;nbsp; The model is your domain model. If you were developing a store, you would probably have models representing an order, customer and a product. The view is your user-interface. This is what your end-user will see. In a web application, your view typically contains HTML. A controller is typically a class that controls the interaction between the model and the view. Once a controller action has been called, it has logic in place that ties both the model and view together.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Separation of Concerns&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The MVC model promotes &lt;a href="http://en.wikipedia.org/wiki/Separation_of_concerns" target="_blank"&gt;separation of concerns (SoC)&lt;/a&gt;. Your model contains the business logic, not presentation logic. Your view should contain presentation logic, not business logic. Why did I say&lt;em&gt; should&lt;/em&gt;? Well, it&amp;#39;s up to the developer.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Learning How to Use MVC Correctly is the Most Difficult Part&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
The framework itself is not hard. Learning how to use a framework properly is hard. Anybody can create a controller, add an action, and then throw text onto a view. Learning how to do that the correct way will take time, though. Sure, you could migrate your WebForms application and place your Page_Load event in an action, create better URLs and call it complete. What are you really buying yourself, though? If you have business logic in your controller, the Single Responsibility principle is now broken because the controller is doing 20 different things. In the end, the only thing you&amp;#39;ve done is migrated from one framework to another and lost a few features you didn&amp;#39;t like. That&amp;#39;s it. You can&amp;#39;t fully harness the testability features of MVC. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Update your Bookshelf or Get to Class&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The best thing you can do is learn software design techniques that are not tied into a specific technology.&amp;nbsp; Take a class on software design, buy a book on software design, read about design patterns and when to use them. Learn about and practice Test-Driven design. There are so many options.&amp;nbsp; 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=gKnA2vq8CEU:b_S1VTL2ElU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=gKnA2vq8CEU:b_S1VTL2ElU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=gKnA2vq8CEU:b_S1VTL2ElU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=gKnA2vq8CEU:b_S1VTL2ElU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=gKnA2vq8CEU:b_S1VTL2ElU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=gKnA2vq8CEU:b_S1VTL2ElU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=gKnA2vq8CEU:b_S1VTL2ElU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/Learning-MVC-is-not-hard3b-Learning-how-to-use-it-correctly-is.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/Learning-MVC-is-not-hard3b-Learning-how-to-use-it-correctly-is.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=e0f576f5-2aa8-4b65-a3b0-6ae57a7c749e</guid>
      <pubDate>Thu, 24 Apr 2008 13:31:00 -0500</pubDate>
      <category>.Software Development</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=e0f576f5-2aa8-4b65-a3b0-6ae57a7c749e</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=e0f576f5-2aa8-4b65-a3b0-6ae57a7c749e</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/Learning-MVC-is-not-hard3b-Learning-how-to-use-it-correctly-is.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=e0f576f5-2aa8-4b65-a3b0-6ae57a7c749e</wfw:commentRss>
    </item>
    <item>
      <title>Testing your ASP.NET MVC Controllers with Moq and xUnit.net</title>
      <description>&lt;p&gt;
I went to the CMAP Code Camp a few weeks ago, and sat in a session about mocking. I wasn&amp;#39;t new to mocking by any means, but I thought it would be useful to listen to other thoughts/opinions. Code Camp sessions, by the way, are a great way to improve your skills. Even if you&amp;#39;re not new to a concept, that doesn&amp;#39;t mean you&amp;#39;re not going to get anything out of it. Code Camp sessions are not like college classes. The speakers don&amp;#39;t just feed you information and tell you to shut-up. The entire environment promotes discussion. Had a problem with something? Would like a second opinion on an idea? Speak up. 
&lt;/p&gt;
&lt;p&gt;
Anyway, the speaker (Scott Allen) walked through a few real-world examples. These examples included some very basic unit tests using xUnit.net. After a while, though, he started mocking a few services with Rhino Mocks. Having used Rhino Mocks previously, I knew what was going on. Right before the end of the session, he took one test and coded it using Moq, another mocking framework that utilizes some of the new C# 3.0 syntax sugar. Before this session I never really took a serious look at Moq, or even xUnit.net. Today, I decided to try both.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The New&amp;#39;ish Guy - xUnit.net&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Another unit testing framework? Yes, but it&amp;#39;s not the same thing packaged up with a new name. xUnit.net has added some new things (Assert Exceptions without Attributes), modified some things (Fact attribute, instead of Test) and removed some things (no TestFixture attribute, no SetUp or TearDown attributes).&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
I know, I know. Why be different? Why have a Fact, instead of a Test? It&amp;#39;s interesting because I felt the same way. Everyone uses the Test attribute, why make it Fact now? After using it for a while, it just makes sense. From my standpoint it just promotes better test names. I feel some people create test names that don&amp;#39;t fully tell the whole story. Fact makes me want to type out a name that should represent a fact. For example, I will be posting some code that will test a method to make sure that, if a domain entity has not been found, will redirect the user. Some people may feel inclined to write &amp;quot;TestRedirect&amp;quot;. But you&amp;#39;re not testing a redirect really. We&amp;#39;re using a framework that we&amp;#39;re not responsible for so the redirect code should work. What we&amp;#39;re trying to test is the interaction between the domain and the controller. When my domain entity is null, I want to call code that redirects the user to a certain page. Wouldn&amp;#39;t a test named &amp;quot;View_Action_Should_Redirect_User_To_Index_If_Ballpark_Is_Not_Found&amp;quot; or something like that make more sense? That&amp;#39;s a fact.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;A Little About Moq&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Moq is a mocking framework that takes advantage of some new language features and helps reduce lines of code in certain areas. It takes certain aspects like Record and Playback, and just hides them behind the scenes. Moq is actually pretty cool. I wouldn&amp;#39;t call it completely mind blowing, but it&amp;#39;s pretty neat. The ability to use new language features and it&amp;#39;s own features to make your tests less verbose is a good thing.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The Example&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;m going to use the scenario I mentioned above. I have a ballpark controller. In it I have an action called &amp;quot;View&amp;quot; that gets a ballpark based on the id passed to it. If the ballpark is found, I want it to display the ballpark details using the &amp;quot;viewballpark&amp;quot; view. However, if my ballpark is not found, I just want to redirect the user to the index action in the same controller. Obviously, this may not be what you want to do. You may want to display an error page. For this example, though, this is what we want to do. I&amp;#39;m not going to use the TDD approach for this example as I have my controller action already coded. I&amp;#39;m going to show you the controller action, a failing test, and then a test that passes.
&lt;/p&gt;
&lt;p&gt;
First, the controller action: 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;pre class="csharp" name="code"&gt;
public ActionResult View(int id)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; Ballpark park = ballparkService.GetBallpark(id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (park == null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return RedirectToAction(&amp;quot;index&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; BallparkControllerViewData viewData = new BallparkControllerViewData {Ballpark = park};
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return RenderView(&amp;quot;view&amp;quot;, viewData);
}
&lt;/pre&gt;
&lt;p&gt;
In my code above, I&amp;#39;m calling my ballpark service to get the ballpark based on the id and then returning what it found. If it&amp;#39;s null, I&amp;#39;m redirecting the user to the index action. If it&amp;#39;s not null, I&amp;#39;m setting up my viewdata and then displaying the view. Pretty simple.
&lt;/p&gt;
&lt;p&gt;
Now, here&amp;#39;s a test that will fail:
&lt;/p&gt;
&lt;pre class="csharp" name="code"&gt;
[Fact]
public void Unknown_Ballpark_Should_Redirect_User_To_Index()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var ballparkServiceMock = new Mock&amp;lt;IBallparkService&amp;gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp; ballparkServiceMock.Expect(x =&amp;gt; x.GetBallpark(It.IsAny&amp;lt;int&amp;gt;())).Returns(new Ballpark());
&amp;nbsp;&amp;nbsp;&amp;nbsp; BallparkController controller = new BallparkController(ballparkServiceMock.Object);
&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var result = controller.View(1) as ActionRedirectResult;
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.ShouldNotBeNull();
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.Values[&amp;quot;action&amp;quot;].ShouldEqual(&amp;quot;index&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; ballparkServiceMock.VerifyAll();
}
&lt;/pre&gt;
&lt;p&gt;
First, what is going on? Using Moq, we&amp;#39;re creating a mocked instance of our ballpark service in the first line of the method. 
&lt;/p&gt;
&lt;p&gt;
Why are we mocking this? Since our ballpark service will eventually communicate with some data source, we don&amp;#39;t want to have our controller unit tests depend on an external data source. For one, this will increase the testing time. If we have to wait for the database every time we want to run our unit tests, this will dramatically increase the amount of time it takes the runner to step through the tests. Second, it&amp;#39;s not very dependable. If we created this test on Monday and used ID 45 because there was no such ballpark with an ID of 45 at the time, the test would work. However, if another developer creates a new ballpark that has an ID of 45 later in the week, the test will now fail. Of course, we could always clean up the data before we execute the test, but that leads me to my next point. Finally, we just don&amp;#39;t care. We&amp;#39;re testing the controller and how it works, not if the database is working. If we test too many things at once, our tests become fragile and brittle. We want to make sure the controller lives up to it&amp;#39;s expectations. In order to accomplish this, we want to control what data is returned. For this reason, we&amp;#39;re going to mock our service.
&lt;/p&gt;
&lt;p&gt;
In the second line, we&amp;#39;re setting our expectations. We&amp;#39;re saying to the mocking framework: For this mock, we have a method called GetBallpark. We expect it to be called. We don&amp;#39;t care what integer it passes in (It.IsAny&amp;lt;int&amp;gt;()). We just want to know if it was called. And if it is called, we want you to return what we tell you. In our expectation, we&amp;#39;re returning a new instance of a ballpark. When the controller calls the service&amp;#39;s GetBallpark method, it will return the new instance.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now, we&amp;#39;re done setting up our expectations. The action is pretty dumb so we don&amp;#39;t expect much from it. Next, we&amp;#39;re going to call our action, pass in some random integer and get the result. Since the code &lt;em&gt;should&lt;/em&gt; redirect the user, we &lt;em&gt;should&lt;/em&gt; expect it to return an instance of ActionRedirectResult. Since we&amp;#39;re casting using the as keyword, it will just set the result variable to null if it cannot cast it. 
&lt;/p&gt;
&lt;p&gt;
All we have to do now is run our assertions to see if what we expected to happen actually happened. 
&lt;/p&gt;
&lt;p&gt;
In this example our test failed. But why? Well, we expected our controller to redirect the user to an action since the ballpark was null. But wait, our ballpark wasn&amp;#39;t null. The ballpark service actually returned an instance of a ballpark because we told it to. Because of this, an ActionRedirectResult was not returned. Instead, a RenderViewResult was returned which caused our cast to fail. Our result variable is now null, which caused the first assert to fail (result.ShouldNotBeNull()).
&lt;/p&gt;
&lt;p&gt;
Fixing this should be pretty easy; we just need to remove the return value in our expectations. 
&lt;/p&gt;
&lt;pre class="csharp" name="code"&gt;
[Fact]
public void Unknown_Ballpark_Should_Redirect_User_To_Index()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var ballparkServiceMock = new Mock&amp;lt;IBallparkService&amp;gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp; ballparkServiceMock.Expect(x =&amp;gt; x.GetBallpark(It.IsAny&amp;lt;int&amp;gt;()));
&amp;nbsp;&amp;nbsp;&amp;nbsp; BallparkController controller = new BallparkController(ballparkServiceMock.Object);
&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var result = controller.View(1) as ActionRedirectResult;
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.ShouldNotBeNull();
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.Values[&amp;quot;action&amp;quot;].ShouldEqual(&amp;quot;index&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; ballparkServiceMock.VerifyAll();
}
&lt;/pre&gt;
&lt;p&gt;
Now, that test works. All we did was remove the return specification from the expect call. Why did that work? 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Mocks - Loose and Strict&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
By default, when you create a mock without specifying a Moq &amp;quot;mockbehavior&amp;quot;, it will create a loose mock, instead of a strict mock. A loose mock can be your friend, but it also can be your enemy. When you use a loose mock, the mocking framework will allow calls to everything, even if you didn&amp;#39;t tell the mock to expect it or give it a return value. Since you didn&amp;#39;t give it a return value, Moq (and Rhino Mocks) will just return that type&amp;#39;s default value. In this case, it will return null for the method. In this example, that&amp;#39;s good for us since our test wants GetBallpark to return null. If we had a strict mock, on the other hand, our test would fail because we didn&amp;#39;t setup the return result.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The Rest of the Assertions&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Since our last test code worked, it went through all of the assertions and passed. Our result variable wasn&amp;#39;t null anymore, since our controller did redirect. Our result values collection contained a key called &amp;quot;action&amp;quot; with the value &amp;quot;index&amp;quot; as it redirected the user to the index action. And finally we verified that all mocking expectations have been met. In this case, they have.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;xUnit.net Extension Methods&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
You may have noticed that our assertions didn&amp;#39;t actually say &amp;quot;Assert&amp;quot; this and &amp;quot;Assert&amp;quot; that. Instead, our assertion methods were called from the variable we were asserting. xUnit.net has several extension methods that created this behavior. In order to add these methods, you must reference the xunit.net 3.5 extension method DLL that&amp;#39;s located in the package. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Closing Up&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;ll post a few more mocking examples shortly. I&amp;#39;ll also post examples on MonoRail controller mocking. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=D4XR7vc7pDc:qoojNJxahrk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=D4XR7vc7pDc:qoojNJxahrk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=D4XR7vc7pDc:qoojNJxahrk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=D4XR7vc7pDc:qoojNJxahrk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=D4XR7vc7pDc:qoojNJxahrk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=D4XR7vc7pDc:qoojNJxahrk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=D4XR7vc7pDc:qoojNJxahrk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/Testing-your-ASPNET-MVC-Controllers-with-Moq-and-xUnitnet.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/Testing-your-ASPNET-MVC-Controllers-with-Moq-and-xUnitnet.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=94ef7848-6c45-40a7-b9ee-19f937766404</guid>
      <pubDate>Wed, 23 Apr 2008 15:47:00 -0500</pubDate>
      <category>.Software Development</category>
      <category>ASP.NET MVC</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=94ef7848-6c45-40a7-b9ee-19f937766404</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=94ef7848-6c45-40a7-b9ee-19f937766404</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/Testing-your-ASPNET-MVC-Controllers-with-Moq-and-xUnitnet.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=94ef7848-6c45-40a7-b9ee-19f937766404</wfw:commentRss>
    </item>
    <item>
      <title>ASP.NET MVC: Testing Controllers Using the Pre-Preview 3 Drop</title>
      <description>&lt;p&gt;
A week or so ago, I wrote &lt;a href="http://www.shanebauer.com/blog/blog/post/2008/04/Using-MvcContribs-TestControllerBuilder-to-Test-Your-ASPNET-MVC-Controllers.aspx" target="_blank"&gt;an entry about controller testing with the ControllerBuilder&lt;/a&gt;. In it I mentioned the &amp;quot;solution&amp;quot; obviously wasn&amp;#39;t the best, and hoped that the work-around we were using wouldn&amp;#39;t be needed for much longer. Well, last Wednesday the &lt;a href="http://weblogs.asp.net/scottgu/archive/2008/04/16/asp-net-mvc-source-refresh-preview.aspx" target="_blank"&gt;MVC team published a preview of preview 3&lt;/a&gt;. There were a number of changes included in this build, but I&amp;#39;m going to talk about controller testing improvements. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What We Did Way Back Last Week&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Last week, we used a test helper from the MvcContrib project. Basically, the controller builder constructed an instance of our controller using Dynamic Proxy and then implemented an interceptor so it could grab data that we could use in our tests. It is quite a bit of work for something so straightforward. All we wanted to do was execute our action and see if it rendered the correct view.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What&amp;#39;s My ActionResult?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If you remember, our controller actions are nothing more than public methods on a controller class. When you call the action from your browser, the ASP.NET MVC simply wires up a request that eventually executes the specified method. Nothing too crazy. The methods didn&amp;#39;t even return anything; they were simply declared void.
&lt;/p&gt;
&lt;p&gt;
Since we&amp;#39;re working with preview releases here, you can&amp;#39;t really expect things not to change. With the latest build, controller methods/actions now return an instance of ActionResult. What is ActionResult? ActionResult is an abstract class that is used to return the result of the action. A result can be a rendered view, a redirect to an action, or even a regular HTTP redirect to another location entirely.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Getting the Result&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now, here&amp;#39;s where you may notice the difference. In our previous controller code, if we wanted to redirect to an action, we could just call RedirectToAction in the middle of the action code and be done with it. RedirectToAction, and the other helper methods, all return instances of some form of ActionResult. RedirectToAction now returns ActionRedirectResult. RenderView returns RenderViewResult. What does this mean? When you call the helper methods, you need return their result now. Here&amp;#39;s an example:
&lt;/p&gt;
&lt;pre class="csharp" name="code"&gt;
public ActionResult Index()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return RenderView(&amp;quot;index&amp;quot;);
}
&lt;/pre&gt;
&lt;p&gt;
As you can see, you just need to ensure you return the result. This result is then used by the framework and you can also use it for testing. The code below illustrates a very simple test using the new build.
&lt;/p&gt;
&lt;pre class="csharp" name="code"&gt;
[Test]
public void BookController_Ensure_Index_Action_Renders_Index_View()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BookController controller = new BookController();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var result = controller.Index() as RenderViewResult;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.IsNotNull(result);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.AreEqual(&amp;quot;index&amp;quot;, result.ViewName);
}
&lt;/pre&gt;
&lt;p&gt;
I&amp;#39;ll have more on this subject, and a real world example that puts them all together in a little while. 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=uJIOeN__e_g:X9axlGNANBg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=uJIOeN__e_g:X9axlGNANBg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=uJIOeN__e_g:X9axlGNANBg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=uJIOeN__e_g:X9axlGNANBg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=uJIOeN__e_g:X9axlGNANBg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=uJIOeN__e_g:X9axlGNANBg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=uJIOeN__e_g:X9axlGNANBg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/ASPNET-MVC-Testing-Controllers-Using-the-Pre-Preview-3-Drop.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/ASPNET-MVC-Testing-Controllers-Using-the-Pre-Preview-3-Drop.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=2ab1951f-751e-4b4c-ae0e-47b3e9d83e79</guid>
      <pubDate>Tue, 22 Apr 2008 06:49:00 -0500</pubDate>
      <category>ASP.NET MVC</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=2ab1951f-751e-4b4c-ae0e-47b3e9d83e79</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=2ab1951f-751e-4b4c-ae0e-47b3e9d83e79</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/ASPNET-MVC-Testing-Controllers-Using-the-Pre-Preview-3-Drop.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=2ab1951f-751e-4b4c-ae0e-47b3e9d83e79</wfw:commentRss>
    </item>
    <item>
      <title>Using MvcContrib's TestControllerBuilder to Test Your ASP.NET MVC Controllers</title>
      <description>&lt;p&gt;
One benefit of ASP.NET MVC (or any MVC framework) is the ability to test your code without having to start up a web server. Sure, you could have always unit tested your model layer, but what if you wanted to ensure that your web application code was interacting correctly with your domain?
&lt;/p&gt;
&lt;h4&gt;A Quick Scenario &lt;br /&gt;
&lt;/h4&gt;
&lt;p&gt;
Lets say, for example, you have an Article controller. The controller has an action called &amp;quot;view&amp;quot;. This action accepts one parameter, an integer, representing the article ID. The action code would then take the ID, and query the database for the article record. What happens if it doesn&amp;#39;t find a record? Obviously, you could do any number of things. You could redirect them to a not found action or just display a different view. To keep things simple in this example, we&amp;#39;ll just redirect the user to the main article page. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Controllers are Test-Friendly, kind of&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
As I said above, a benefit of the MVC framework is the ability to test your code without having to bother with ugly hacks to manipulate a web server and/or the ASP.NET pipeline. The ASP.NET MVC is an improvement in this area without a doubt. However, it&amp;#39;s not perfect. There are areas in which you cannot test easily. RedirectData, for example, is one example of something that&amp;#39;s difficult to test. There are ways to work around this limitation, but they are exactly that: a work-around. Fortunately, the MVC team has recognized a few areas that could be improved and are actively addressing our concerns for the next preview.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Introducing the TestControllerBuilder&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://www.mvccontrib.org" target="_blank"&gt;MvcContrib&lt;/a&gt; project is an open source project that boasts quite a few additional features you can add to your project. For example, MvcContrib offers a variety of controller factories that integrate will all of the major IoC containers. In addition, MvcContrib also has a collection of view engines you can use if you&amp;#39;re not satisfied with the WebForms view engine that&amp;#39;s enabled by default. 
&lt;/p&gt;
&lt;p&gt;
The TestControllerBuilder is another contribution that&amp;#39;s also available in this project. TestControllerBuilder uses a dynamic proxy and an interceptor to relieve some of the pain behind controller testing. Below is a sample test using the TestControllerBuilder, Rhino Mocks and MbUnit. In order for this to work, I need to make sure my mock instance of IArticleService returns a null instance. I&amp;#39;m using Rhino Mocks &amp;quot;SetupResult&amp;quot; for this. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;
[Test]
public void Unknown_Article_Redirects_To_Index()
{
TestControllerBuilder builder = new TestControllerBuilder();
ArticleController controller = builder.CreateController&amp;lt;ArticleController&amp;gt;(new object[] { articleService });
SetupResult.For(articleService.GetArticle(1)).IgnoreArguments().Return(null);
controller.View(1);
Assert.AreEqual(builder.RedirectToActionData.ActionName, &amp;quot;index&amp;quot;);
}
&lt;/pre&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now, here&amp;#39;s the action implementation.
&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;
public void View(int id)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; Article article = articleService.GetArticle(id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (article == null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RedirectToAction(&amp;quot;index&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; ArticleControllerViewData viewData = new ArticleControllerViewData {Article = article};&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; RenderView(&amp;quot;view&amp;quot;, viewData);
}
&lt;/pre&gt;
&amp;nbsp;
&lt;p&gt;
&lt;strong&gt;Changes are Coming&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
As I mentioned above, changes are coming. I&amp;#39;m not sure how long this code will be appropriate (hopefully not long). Either way, I thought it was worth mentioning.&amp;nbsp; 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ln25fQheZN0:0C_Sxfm7gwo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ln25fQheZN0:0C_Sxfm7gwo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=ln25fQheZN0:0C_Sxfm7gwo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ln25fQheZN0:0C_Sxfm7gwo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ln25fQheZN0:0C_Sxfm7gwo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=ln25fQheZN0:0C_Sxfm7gwo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=ln25fQheZN0:0C_Sxfm7gwo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/Using-MvcContribs-TestControllerBuilder-to-Test-Your-ASPNET-MVC-Controllers.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/Using-MvcContribs-TestControllerBuilder-to-Test-Your-ASPNET-MVC-Controllers.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=75b85a96-5f20-4fd8-9250-48c65159ce82</guid>
      <pubDate>Mon, 14 Apr 2008 06:40:00 -0500</pubDate>
      <category>ASP.NET MVC</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=75b85a96-5f20-4fd8-9250-48c65159ce82</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=75b85a96-5f20-4fd8-9250-48c65159ce82</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/Using-MvcContribs-TestControllerBuilder-to-Test-Your-ASPNET-MVC-Controllers.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=75b85a96-5f20-4fd8-9250-48c65159ce82</wfw:commentRss>
    </item>
    <item>
      <title>CMAP Code Camp Spring 2008</title>
      <description>&lt;p&gt;
I went to the &lt;a href="http://www.cmap-online.org/CodeCamp/Default.aspx" target="_blank"&gt;Spring 2008 CMAP Code Camp&lt;/a&gt; yesterday with a &lt;a href="http://blog.joelowrance.com" target="_blank"&gt;friend and former co-worker yesterday&lt;/a&gt;. A lot of good sessions all around.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;A Gentle Introduction to Mocking -&amp;nbsp; &lt;a href="http://odetocode.com/blogs/scott/default.aspx" target="_blank"&gt;Scott Allen&lt;/a&gt; discussed the basics of mocking with &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx" target="_blank"&gt;Rhino Mocks&lt;/a&gt;. Later, he switched it up for a test and used &lt;a href="http://code.google.com/p/moq/" target="_blank"&gt;Moq&lt;/a&gt;. Pretty interesting stuff. Nothing completely mind blowing, but it was a little different. He also used &lt;a href="http://www.codeplex.com/xunit" target="_blank"&gt;xUnit.net&lt;/a&gt; as the unit testing framework. That was the first time that I had a good look at xUnit.net and Moq. Thanks Scott.
&lt;/p&gt;
&lt;p&gt;
C# 3.0 New Features - &lt;a href="http://msmvps.com/blogs/vcsjones/" target="_blank"&gt;Kevin Jones&lt;/a&gt; discussed all of the new features of C# 3.0. Lambda expressions, anonymous types, LINQ and everything else. Thanks Kevin.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;Decouple Your Applications with Dependency Injection and IoC Containers - &lt;a href="http://weblogs.asp.net/Podwysocki" target="_blank"&gt;Matthew Podwysocki&lt;/a&gt; discussed quite a few different things related to dependency injection and IoC Containers. He also gave a few demos using &lt;a href="http://www.castleproject.org/container/index.html" target="_blank"&gt;Windsor&lt;/a&gt; as well as &lt;a href="http://www.codeplex.com/unity" target="_blank"&gt;Unity&lt;/a&gt;. Thanks Matthew
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;Create AJAX Applications Using JQuery and ASP.NET MVC - &lt;a href="http://www.emadibrahim.com/" target="_blank"&gt;Emad Ibrahim&lt;/a&gt; had a session on &lt;a href="http://www.asp.net/mvc/" target="_blank"&gt;ASP.NET MVC&lt;/a&gt; and &lt;a href="http://www.jquery.com"&gt;jQuery&lt;/a&gt;. He gave a good overview of a few ASP.NET MVC features and dove into jQuery. Given the short amount of time, he was able to show a few of jQuery&amp;#39;s powerful features and even demo a site that he&amp;#39;s created using both, &lt;a href="http://www.yonkly.com" target="_blank"&gt;Yonkly.&lt;/a&gt; Thanks Emad.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;Free sessions, free food, free prizes. You really can&amp;#39;t beat it. Thanks to the CMAP group and the volunteers. 
&lt;/p&gt;
&lt;p&gt;
My goal is to blog about a these few areas shortly.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp; 
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=FkTUzszRIa8:EzLjwJ7FVY4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=FkTUzszRIa8:EzLjwJ7FVY4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=FkTUzszRIa8:EzLjwJ7FVY4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=FkTUzszRIa8:EzLjwJ7FVY4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=FkTUzszRIa8:EzLjwJ7FVY4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=FkTUzszRIa8:EzLjwJ7FVY4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=FkTUzszRIa8:EzLjwJ7FVY4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/CMAP-Code-Camp-Spring-2008.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/CMAP-Code-Camp-Spring-2008.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=d45e2629-08e0-4959-a577-ba95f4a0296e</guid>
      <pubDate>Sun, 13 Apr 2008 09:21:00 -0500</pubDate>
      <category>.NET</category>
      <category>.Software Development</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=d45e2629-08e0-4959-a577-ba95f4a0296e</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=d45e2629-08e0-4959-a577-ba95f4a0296e</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/CMAP-Code-Camp-Spring-2008.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=d45e2629-08e0-4959-a577-ba95f4a0296e</wfw:commentRss>
    </item>
    <item>
      <title>New Blog, New Start</title>
      <description>I setup a new blog. I wasn&amp;#39;t happy with my previous blogging software. With this change I hope to become much more active. I&amp;#39;m still thinking about a few topics, but I will generally stay around the .NET, ASP.NET, Web and Software Development genre.&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SsjljrfiiCE:dXNo09Nidj4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SsjljrfiiCE:dXNo09Nidj4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=SsjljrfiiCE:dXNo09Nidj4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SsjljrfiiCE:dXNo09Nidj4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SsjljrfiiCE:dXNo09Nidj4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=SsjljrfiiCE:dXNo09Nidj4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=SsjljrfiiCE:dXNo09Nidj4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2008/04/New-Blog2c-New-Start.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2008/04/New-Blog2c-New-Start.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=6af28fde-d487-4c85-bf41-f9911e46afcb</guid>
      <pubDate>Sun, 13 Apr 2008 09:19:00 -0500</pubDate>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=6af28fde-d487-4c85-bf41-f9911e46afcb</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=6af28fde-d487-4c85-bf41-f9911e46afcb</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2008/04/New-Blog2c-New-Start.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=6af28fde-d487-4c85-bf41-f9911e46afcb</wfw:commentRss>
    </item>
    <item>
      <title>ASP.NET: Web Controls have an ID, a ClientID and a UniqueID. What's the deal?</title>
      <description>&lt;div class="itemBodyStyle"&gt;
&lt;p&gt;
While working on your ASP.NET page,
you may have&amp;nbsp;noticed that all of your web controls contain three
different ID properties. That&amp;#39;s great. But why? Uniqueness.
&lt;/p&gt;
&lt;p&gt;
Lets say, for example, you have a Repeater control. In this Repeater
control, you have an itemtemplate that contains a textbox and a label.
Your label is called &amp;quot;ProductName&amp;quot; and your textbox is called
&amp;quot;ProductQuantity&amp;quot;. If your repeater contained more than one item, you
would run into issues with html elements being named the same. That&amp;#39;s a
huge problem. 
&lt;/p&gt;
&lt;p&gt;
UniqueID fixes this issue. When the control gets created, a uniqueId
is generated based on the control&amp;#39;s heirarchy. For example, a textbox
within a CreateUserWizard would have a UniqueID similar to
&amp;quot;CreateUserWizard1$CreateUserStepContainer$Email&amp;quot;. The UniqueID, as you
can see, is a large string seperating the control&amp;#39;s parents by a dollar
sign. Pretty simple.
&lt;/p&gt;
&lt;p&gt;
However, that&amp;#39;s not technically valid in the HTML world. ClientID
fixes this problem. ClientID replaces the invalid separator with a
valid separator, like an underscore. Therefore, the textbox within the
CreateUserWizard would have a ClientID similar to
&amp;quot;CreateUserWizard1_CreateUserStepContainer_Email&amp;quot;. As a result, when
your textbox is rendered as a standard input element, the ID field
would contain the value in the ClientID property.
&lt;/p&gt;
&lt;p&gt;
If you want to access your control via javascript, don&amp;#39;t use the ID
property, and don&amp;#39;t use the UniqueID property. Use the ClientID
Property. 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent"&gt;ConfirmButton.Attributes.Add(&lt;span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4"&gt;&amp;quot;OnClick&amp;quot;&lt;/span&gt;,&lt;span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4"&gt;&amp;quot;javascript: alert(&amp;#39;The username textbox as a value of &amp;quot;&lt;/span&gt; &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent"&gt;+&lt;/span&gt; Username.ClientID &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent"&gt;+&lt;/span&gt; &lt;span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4"&gt;&amp;quot;&amp;#39;)&amp;quot;&lt;/span&gt;;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=GK292Ju_-p4:C40a_8d4dNc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=GK292Ju_-p4:C40a_8d4dNc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=GK292Ju_-p4:C40a_8d4dNc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=GK292Ju_-p4:C40a_8d4dNc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=GK292Ju_-p4:C40a_8d4dNc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=GK292Ju_-p4:C40a_8d4dNc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=GK292Ju_-p4:C40a_8d4dNc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2006/11/ASPNET-Web-Controls-have-an-ID2c-a-ClientID-and-a-UniqueID-Whats-the-deal.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2006/11/ASPNET-Web-Controls-have-an-ID2c-a-ClientID-and-a-UniqueID-Whats-the-deal.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=e1874202-ff22-4017-a48f-dc9960b97f9c</guid>
      <pubDate>Wed, 08 Nov 2006 11:05:00 -0500</pubDate>
      <category>.NET</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=e1874202-ff22-4017-a48f-dc9960b97f9c</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=e1874202-ff22-4017-a48f-dc9960b97f9c</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2006/11/ASPNET-Web-Controls-have-an-ID2c-a-ClientID-and-a-UniqueID-Whats-the-deal.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=e1874202-ff22-4017-a48f-dc9960b97f9c</wfw:commentRss>
    </item>
    <item>
      <title>Stored Procedures and .NET Part II: Using Output Parameters and Return Values</title>
      <description>&lt;p&gt;
Yesterday, I created a simple stored procedure and used it inside an ASP.NET project. In that example, we used standard Input parameters to insert a record into our users table. 
&lt;/p&gt;
&lt;p&gt;
In today&amp;#39;s example, we are going to use the same users table, but add two more touches to it. First, we are going to use an&amp;nbsp;Output parameter to return the value of the user&amp;#39;s unique ID number. Second, we are going to do the same thing, except with a return value.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Output Parameters&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Lets begin with an output parameter example. In this first example, I want to add a user into my table and then get the unique id back. In order to do this, we&amp;#39;ll use an output parameter. 
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;p&gt;
AddUserOutput.sql&lt;br /&gt;
-----------------------------------------------------------------
&lt;/p&gt;
&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;Create Procedure &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;dbo.AddUserOutput&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;(&lt;br /&gt;
@username &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50),&lt;br /&gt;
@first_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50),&lt;br /&gt;
@last_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50),&lt;br /&gt;
@user_id &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;int output&lt;br /&gt;
&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;
&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;AS&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;insert into &lt;/font&gt;&lt;font size="2" color="#222222"&gt;tblUsers(username,first_name,last_name) &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;values&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;(@username,@first_name,@last_name)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;select &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;@user_id=SCOPE_IDENTITY() &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;
&lt;/div&gt;
&lt;p&gt;
This should look very similiar to yesterday&amp;#39;s example. The only thing I&amp;#39;ve added is the extra output parameter and the code used to select the unique id. The output parameter is declared as @user_id with a data type of int and the flag &amp;ldquo;output&amp;rdquo; added to it. This lets MSSQL know that it shouldn&amp;#39;t be expecting any initial value for it.
&lt;/p&gt;
&lt;p&gt;
In order to actually get the unique id, we use
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;select &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;@user_id=SCOPE_IDENTITY() &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;
&lt;/div&gt;
&lt;p&gt;
This line takes our output parameter, @user_id, and sets it equal to the latest unique id in the users table. SCOPE_IDENTITY() is a function that returns the latest unique id created for any table used in this session.
&lt;/p&gt;
&lt;p&gt;
Now that we have created our stored procedure, we can jump into the C# code. Again, the code for this part will look very similiar to the C# code in yesterday&amp;#39;s example, with a few minor adjustments. 
&lt;/p&gt;
&lt;p&gt;
First, we need to add our new output parameter, @user_id.
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;pre class="csharpcode"&gt;
SqlParameter param4 = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter();
param4.ParameterName = &lt;span class="str"&gt;&amp;quot;@user_id&amp;quot;&lt;/span&gt;;
param4.SqlDbType = SqlDbType.Int;
param4.Direction = ParameterDirection.Output;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
In the code above, I created a new SqlParameter with a name of @user_id and the ParameterDirection is set as output. By default, all parameters have a direction of input, so you will need to change that if you&amp;#39;re using Output parameters. Once you have created the new parameter, add the parameter to the parameters collection.
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;pre class="csharpcode"&gt;
cmd.Parameters.Add(param4);
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Finally, we need to get our output parameter value once our procedure has been executed. To do this, you will need to do the following.
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;pre class="csharpcode"&gt;
conn.Open();
cmd.ExecuteNonQuery();
ltlUserId.Text = cmd.Parameters[&lt;span class="str"&gt;&amp;quot;@user_id&amp;quot;&lt;/span&gt;].Value.ToString();
conn.Close();
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
After I executed my stored procedure, I got my output parameter value by using the Value property. That&amp;#39;s all there is to it.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Return Values&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Using return values is almost exactly similiar to output parameters, but with a few exceptions.
&lt;/p&gt;
&lt;p&gt;
- Return values are integers, only.&lt;br /&gt;
- You do not need to declare a parameter in the stored procedure code&lt;br /&gt;
- You do need to create a parameter in your C#/VB.net code, but the parameter name is &amp;ldquo;RETURN_VALUE&amp;rdquo; and the ParameterDirection is &amp;ldquo;ParameterDirection.ReturnValue&amp;ldquo;.&lt;br /&gt;
- To get the return value, you would type in: cmd.Parameters[&amp;rdquo;RETURN_VALUE&amp;rdquo;].Value;
&lt;/p&gt;
&lt;p&gt;
Instead of going over every detail, I&amp;#39;ll put the stored procedure code below, as well as the C# code.
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;p&gt;
AddUserReturn.sql&lt;br /&gt;
-------------------------------------------------------------------------------------
&lt;/p&gt;
&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;Create Procedure &lt;/font&gt;&lt;font size="2" color="#222222"&gt;dbo.AddUserReturn&lt;br /&gt;
(&lt;br /&gt;
@username &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2" color="#222222"&gt;(50),&lt;br /&gt;
@first_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2" color="#222222"&gt;(50),&lt;br /&gt;
@last_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;(50)&lt;br /&gt;
)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;AS&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;declare &lt;/font&gt;&lt;font size="2" color="#222222"&gt;@user_id &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;int&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;insert into &lt;/font&gt;&lt;font size="2" color="#222222"&gt;tblUsers(username,first_name,last_name) &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;values&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;(@username,@first_name,@last_name)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;select &lt;/font&gt;&lt;font size="2" color="#222222"&gt;@user_id=@@IDENTITY &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;from &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;tblUsers&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;return &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;@user_id&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;
&lt;/div&gt;
&lt;p&gt;
C# Code&lt;br /&gt;
--------------------------------------------------------------------
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class="csharpcode"&gt;
SqlConnection conn = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlConnection(&lt;span class="str"&gt;&amp;quot;conn_string_here;&amp;quot;&lt;/span&gt;);
SqlCommand cmd = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlCommand(&lt;span class="str"&gt;&amp;quot;AddUserReturn&amp;quot;&lt;/span&gt;,conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@username&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);
param.Value = &lt;span class="str"&gt;&amp;quot;sbauer&amp;quot;&lt;/span&gt;;
SqlParameter param2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@first_name&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);
param2.Value = &lt;span class="str"&gt;&amp;quot;Shane&amp;quot;&lt;/span&gt;;
SqlParameter param3 = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@last_name&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);
param3.Value = &lt;span class="str"&gt;&amp;quot;Bauer&amp;quot;&lt;/span&gt;;
SqlParameter param4= &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;RETURN_VALUE&amp;quot;&lt;/span&gt;,SqlDbType.Int);
param4.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(param);
cmd.Parameters.Add(param2);
cmd.Parameters.Add(param3);
cmd.Parameters.Add(param4);
conn.Open();
cmd.ExecuteNonQuery();
ltlUserId.Text = cmd.Parameters[&lt;span class="str"&gt;&amp;quot;RETURN_VALUE&amp;quot;&lt;/span&gt;].Value.ToString();
conn.Close();
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
I hope you found my quick overview useful.
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=6L9dZlbEVWs:LZnLqhch388:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=6L9dZlbEVWs:LZnLqhch388:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=6L9dZlbEVWs:LZnLqhch388:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=6L9dZlbEVWs:LZnLqhch388:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=6L9dZlbEVWs:LZnLqhch388:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=6L9dZlbEVWs:LZnLqhch388:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=6L9dZlbEVWs:LZnLqhch388:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-II-Using-Output-Parameters-and-Return-Values.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-II-Using-Output-Parameters-and-Return-Values.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=e4745e9f-76db-46d4-8b25-e31e249e2133</guid>
      <pubDate>Sun, 14 Nov 2004 00:19:00 -0500</pubDate>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=e4745e9f-76db-46d4-8b25-e31e249e2133</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=e4745e9f-76db-46d4-8b25-e31e249e2133</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-II-Using-Output-Parameters-and-Return-Values.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=e4745e9f-76db-46d4-8b25-e31e249e2133</wfw:commentRss>
    </item>
    <item>
      <title>Stored Procedures and .NET Part I: Executing Simple Stored Procedures</title>
      <description>&lt;p&gt;
For what it&amp;#39;s worth, I enjoy using&amp;nbsp;Stored Procedures. I know there have been quite a few debates over the last year regarding myths and facts involving them, but I would rather not get into that right now. Instead, I&amp;#39;m going to show a few stored procedure examples. 
&lt;/p&gt;
&lt;p&gt;
Stored Procedures allow you to store all database-related queries and other transactions inside of the database. Some argue about the actual benefits, but either way, they have a place in the database world.
&lt;/p&gt;
&lt;p&gt;
Before&amp;nbsp;I continue, you must know that stored procedures accept three types of parameters: input, output and return. Input parameters take data from the outside world into the stored procedure. Try to think of a standard function in any programming language and the parameters they accept. Those parameters are similiar to stored procedure input parameters. 
&lt;/p&gt;
&lt;p&gt;
In my first example, I&amp;#39;m going to create a simple stored procedure that INSERTs a record in a table. 
&lt;/p&gt;
&lt;p&gt;
AddUser.sql&lt;br /&gt;
-----------------------------------------------------------------
&lt;/p&gt;
&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;Create Procedure &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;dbo.AddUser &lt;br /&gt;
(&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;@username &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50),&lt;br /&gt;
@first_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50),&lt;br /&gt;
@last_name &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;varchar&lt;/font&gt;&lt;font size="2"&gt;(50)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2"&gt;)&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;AS&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="2" color="#0000ff"&gt;insert into &lt;/font&gt;&lt;font size="2" color="#222222"&gt;tblUsers(username,first_name,last_name) &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;values&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#222222"&gt;(@username,@first_name,@last_name)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;
&lt;p&gt;
In this example, my stored procedure, AddUser, is owned by the dbo and takes three input parameters: @username,@first_name, and @last_name. In addition, it inserts these values into the tblUsers table. 
&lt;/p&gt;
&lt;p&gt;
Since the SQL statement is inside of the procedure, you won&amp;#39;t need to execute the same INSERT command inside of your .NET. Instead, you will call the stored procedure and specify the parameter values. But first, lets create our connection and command objects.
&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class="csharpcode"&gt;
SqlConnection conn = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlConnection(&lt;span class="str"&gt;&amp;quot;connection_string_here;&amp;quot;&lt;/span&gt;);
SqlCommand cmd = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlCommand(&lt;span class="str"&gt;&amp;quot;AddUser&amp;quot;&lt;/span&gt;,conn);
cmd.CommandType = CommandType.StoredProcedure;
&lt;/pre&gt;
&lt;p&gt;
The code above creates our connection object, conn, and sets the connection string. Depending on your database information, you will need to change that. After that, our command object, cmd, is created. For the purpose of this example, the SqlCommand constructor takes two parameters: the text for the sql command and a connection instance. Because our stored procedure is called &amp;ldquo;AddUser&amp;rdquo;, we specify that in our first parameter and type conn in our second parameter. You&amp;#39;ll also notice that I have specified a commandtype. This tells ADO.NET that we are trying to execute a stored procedure, not a standard ad-hoc query. If you forgot that portion, you would get an error because AddUser is not a valid SQL command.
&lt;/p&gt;
&lt;p&gt;
Next, we need to specify our parameters. If you didn&amp;#39;t specify any parameters in your stored procedure, you wouldn&amp;#39;t need to write the following lines of code. However, since I did, I need to specify the parameters or else&amp;nbsp;my application&amp;nbsp;would complain.
&lt;/p&gt;
SqlParameter param = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@username&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);&lt;br /&gt;
&lt;pre class="csharpcode"&gt;
param.Value = &lt;span class="str"&gt;&amp;quot;sbauer&amp;quot;&lt;/span&gt;;
SqlParameter param2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@first_name&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);
param2.Value = &lt;span class="str"&gt;&amp;quot;Shane&amp;quot;&lt;/span&gt;;
SqlParameter param3 = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlParameter(&lt;span class="str"&gt;&amp;quot;@last_name&amp;quot;&lt;/span&gt;,SqlDbType.VarChar);
param3.Value = &lt;span class="str"&gt;&amp;quot;Bauer&amp;quot;&lt;/span&gt;;
cmd.Parameters.Add(param);
cmd.Parameters.Add(param2);
cmd.Parameters.Add(param3);
&lt;/pre&gt;
&lt;p&gt;
In the piece of code above, I have created three SqlParameter objects (one for each parameter). In the constructor for each one, I&amp;#39;ve specified the parameter name, and the database data type. As you can tell, our parameter name and data type match what it is in stored procedure. After we initiate each object, I then had to specify the value. I simply used hard-coded strings, such as &amp;ldquo;Shane&amp;rdquo; and &amp;ldquo;Bauer&amp;rdquo;, but you can use variables as well.
&lt;/p&gt;
&lt;p&gt;
Once you have created each parameter, you must put each parameter inside of the command object&amp;#39;s parameters collection. To do this, you simply do: cmd.Parameters.Add(YOUR_PARAM_OBJ_HERE).
&lt;/p&gt;
&lt;p&gt;
Once you have added your parameters to the collection, all you need to do is open the connection, execute the command and close the connection. Because our command doesn&amp;#39;t return a resultset, you can use the ExecuteNonQuery() method of the SqlCommand object.
&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;conn.Open();&lt;br /&gt;
&lt;pre class="csharpcode"&gt;
cmd.ExecuteNonQuery();
conn.Close();
&lt;/pre&gt;
&lt;p&gt;
Assuming you have setup the database correctly, your command should execute. 
&lt;/p&gt;
&lt;p&gt;
If you want to know more technical details about stored procedures, check out a few sites on the web. My goal was to give a brief overview of stored procedures, while showing you how to use them in .NET. Tomorrow, I will explain Output and Return value parameters.
&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=TrZfqRBL5FM:K9l50PKi6-U:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=TrZfqRBL5FM:K9l50PKi6-U:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=TrZfqRBL5FM:K9l50PKi6-U:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=TrZfqRBL5FM:K9l50PKi6-U:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=TrZfqRBL5FM:K9l50PKi6-U:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?i=TrZfqRBL5FM:K9l50PKi6-U:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sbauer?a=TrZfqRBL5FM:K9l50PKi6-U:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sbauer?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <link>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-I-Executing-Simple-Stored-Procedures.aspx</link>
      <author>sbauer</author>
      <comments>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-I-Executing-Simple-Stored-Procedures.aspx#comment</comments>
      <guid>http://www.shanebauer.com/blog/post.aspx?id=c954e99b-3ac6-4d5d-b2d1-e0d6f2776f99</guid>
      <pubDate>Sat, 13 Nov 2004 00:16:00 -0500</pubDate>
      <category>.NET</category>
      <dc:publisher>sbauer</dc:publisher>
      <pingback:server>http://www.shanebauer.com/blog/pingback.axd</pingback:server>
      <pingback:target>http://www.shanebauer.com/blog/post.aspx?id=c954e99b-3ac6-4d5d-b2d1-e0d6f2776f99</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.shanebauer.com/blog/trackback.axd?id=c954e99b-3ac6-4d5d-b2d1-e0d6f2776f99</trackback:ping>
      <wfw:comment>http://www.shanebauer.com/blog/post/2004/11/Stored-Procedures-and-NET-Part-I-Executing-Simple-Stored-Procedures.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.shanebauer.com/blog/syndication.axd?post=c954e99b-3ac6-4d5d-b2d1-e0d6f2776f99</wfw:commentRss>
    </item>
  </channel>
</rss>
