<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Mister James on .NET</title><link>http://www.jameschambers.com:80/blog</link><description>Mister James on .NET</description><item><title>Removing Tracked Files After Adding A Rule to .gitignore</title><link>http://www.jameschambers.com:80/blog/removing-tracked-files-after-adding-a-rule-to-.gitignore</link><description>&lt;p&gt;As I learn some of the workings of git in the normal flow of daily use, I struggled for a few minutes this afternoon trying to scrub a directory of DLLs that had been committed to a repo.&amp;nbsp; These files were previously tracked, so even though the rule was correct, git wasn’t dropping tracking to the files.&lt;/p&gt; &lt;p&gt;Here’s the fix from the mouth of the horse:&lt;/p&gt; &lt;blockquote&gt; &lt;h4&gt;.gitignore&lt;/h4&gt; &lt;p&gt;If you create a file in your repo named &lt;code&gt;.gitignore&lt;/code&gt; git will use its rules when looking at files to commit. Note that git will &lt;strong&gt;not&lt;/strong&gt; ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with &lt;code&gt;git rm --cached filename&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;There ya be.&amp;nbsp; So, create your rule, rm the files and &lt;em&gt;then&lt;/em&gt; do your git status to see the changes.&amp;nbsp; The removing them from tracking is also a change that will have to be committed.&lt;/p&gt;</description><pubDate>Thu, 10 May 2012 18:54:55 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/removing-tracked-files-after-adding-a-rule-to-.gitignore</guid></item><item><title>Cloudy With a Chance of Mobile: Building Our Data Model &amp; API</title><link>http://www.jameschambers.com:80/blog/cloudy-with-a-chance-of-mobile-building-our-data-model-amp-api</link><description>&lt;blockquote&gt;
&lt;p&gt;Interested in having a web site that supports user-specific data? Perfect, use Asp.Net and the built in membership providers. Want to put it in the cloud? Sweet, jump on the Azure bandwagon. Want to easily define your data model and store it? No worries, EF Code First will make you cry, you love it so much. Want to access that data from Windows Phone? Well, my friend, you've come to the right place. If you want to follow along from the beginning, please check out the &lt;a href="http://jameschambers.com/blog/cloudy-with-a-chance-of-mobile-mvc-framework-windows-azure-and-windows-phone" target="_blank"&gt;first post in the series&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;With my projects roughly set up the way I'd like them to be I can now start building my data model using Entity Framework or "EF".&amp;nbsp; I'll use the model definition to quickly scaffold some UI and add some data to my project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;I will then expose that data via the new Web API available in Mvc 4.&amp;nbsp; Though I have two solutions set up, I'll only be working in the Mvc 4 project for this tutorial.&amp;nbsp; A reminder that if you're opening the IDE to follow along after a break you'll need to open it up in Administrator mode for the Azure environment to run correctly.&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span color="#666666" style="color: #666666;"&gt;Our Data Class&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;To keep things simple I'm going to use a single entity class &amp;ndash; and ultimately a single table &amp;ndash; for this exercise.&amp;nbsp; In the Mvc 4 project, use the Solution Explorer to locate and then right-click on the Models folder to add a new class called PhoneNumberEntry.&amp;nbsp; The class will look like the following:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; PhoneNumberEntry
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; PhoneNumberEntryId { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FirstName { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LastName { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PhoneNumber { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; UserName { get; set; }
    }&lt;/pre&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;Hey, don't judge. I said I was keeping it simple. &lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/wlEmoticon-winkingsmile_2.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;Next, I need to tell EF how to create the database, namely, I have to tell it what tables to create and of which entity. I do this through inheritance and attributes on our classes.&amp;nbsp; You can put this definition in the same file as the PhoneNumberEntry class.&amp;nbsp; Again, it's very light weight.&lt;/span&gt;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactContext: DbContext
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; DbSet&amp;lt;PhoneNumberEntry&amp;gt; PhoneNumberEntries { get; set; }
    }&lt;/pre&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;Perfect, now I'm rolling. To create the UI, I'm simply going to use the tooling that's built into the MVC Framework through Visual Studio 2010. In order to fully leverage this, I need to compile my classes so that the IDE can reflect on my project and show me a list of them.&amp;nbsp; I like to use the keyboard shortcut Shift + Ctrl + B to build. &lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span color="#666666" style="color: #666666;"&gt;Building the Views&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span color="#666666" style="color: #666666;"&gt;With my project compiled, I right-click on the Controllers folder in Project Explorer and select Add &amp;ndash;&amp;gt; Controller. I name my controller appropriately, select my PhoneNumberEntry class and name a new Data Context Class.&amp;nbsp; I choose the Controller with read/write actions and views, using Entity Framework as the template.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_3.png" width="384" height="250" /&gt;&lt;/p&gt;
&lt;p&gt;The tooling builds my controller and scaffolds out my views for me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I only want members who have registered to create entries, and I want to each user to have their own list. I created a UserName property on my model, so I now need to deal with that field on my own. In my Create and Edit views, I remove the UserName field. Here's an example of what that HTML looked like before I removed it:&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_6.png" width="412" height="125" /&gt;&lt;/p&gt;
&lt;p&gt;With that out of the way (in both Create and Edit) I need to update my controller accordingly. I open PhoneNumberEntryController in the Controllers folder and add the Authorize attribute to my class.&amp;nbsp;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    [Authorize]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; PhoneNumberEntryController : Controller
    {
        &lt;span class="rem"&gt;// ...rest of class here&lt;/span&gt;
    }&lt;/pre&gt;
&lt;p&gt;By attributing the controller in this way (at the class level), I am telling the Asp.Net runtime that any user who accesses any action on this controller needs to be logged in using the authentication scheme of the site.&amp;nbsp; Now, all users who try to navigate to any of my Phone Numbers pages will first be prompted to log in.&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_9.png" width="260" height="142" /&gt;&lt;/p&gt;
&lt;h2&gt;Driven By the Logged in User&lt;/h2&gt;
&lt;p&gt;Next, I want to make sure that the user only ever sees the phone numbers that they create.&amp;nbsp; The index method needs to be adjusted to only return the appropriate entries.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()
    {
        &lt;span class="kwrd"&gt;string&lt;/span&gt; username = User.Identity.Name;

        var phoneNumbers = db.PhoneNumberEntries
            .Where(p =&amp;gt; p.UserName == username)
            .ToList();

        &lt;span class="kwrd"&gt;return&lt;/span&gt; View(phoneNumbers);
    }&lt;/pre&gt;
&lt;p&gt;In the Create and Edit methods decorated with the HttpPost attribute (these are the methods that accept the PhoneNumberEntry parameters from the form) I add a bit of code to capture the user's login name and store that in the model.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    [HttpPost]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Create(PhoneNumberEntry phonenumberentry)
    {
        &lt;span class="kwrd"&gt;string&lt;/span&gt; username = User.Identity.Name;
        phonenumberentry.UserName = username;

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (ModelState.IsValid)
        {
            db.PhoneNumberEntries.Add(phonenumberentry);
            db.SaveChanges();
            &lt;span class="kwrd"&gt;return&lt;/span&gt; RedirectToAction(&lt;span class="str"&gt;"Index"&lt;/span&gt;);
        }

        &lt;span class="kwrd"&gt;return&lt;/span&gt; View(phonenumberentry);
    }&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;: There are many more security considerations to take and I am only demonstrating some bare minimums. In a real-world scenario you would use a repository outside of the controller and would do the appropriate checks to protect your data at various levels of your project. Particularly, any code to retrieve or modify the data should have checks in place to ensure the user is authorized to view or modify the resource in question.&amp;nbsp; As an exercise to the reader, work through the PhoneNumberEntryController and firm up the user access/rights to a better degree.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Everything should be set here to capture some data, but I want to be able to easily access these bits of UI.&amp;nbsp; I open up my _Layout.cshtml file, located in Views\Shared in the Solution Explorer and modify the snippet of code that creates the menu elements.&amp;nbsp; When finished, it looks like so:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    &amp;lt;nav&amp;gt;
        &amp;lt;ul id=&lt;span class="str"&gt;"menu"&lt;/span&gt;&amp;gt;
            &amp;lt;li&amp;gt;@Html.ActionLink(&lt;span class="str"&gt;"Home"&lt;/span&gt;, &lt;span class="str"&gt;"Index"&lt;/span&gt;, &lt;span class="str"&gt;"Home"&lt;/span&gt;)&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;@Html.ActionLink(&lt;span class="str"&gt;"About"&lt;/span&gt;, &lt;span class="str"&gt;"About"&lt;/span&gt;, &lt;span class="str"&gt;"Home"&lt;/span&gt;)&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;@Html.ActionLink(&lt;span class="str"&gt;"Phone Numbers"&lt;/span&gt;, &lt;span class="str"&gt;"Index"&lt;/span&gt;, &lt;span class="str"&gt;"PhoneNumberEntry"&lt;/span&gt;)&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;@Html.ActionLink(&lt;span class="str"&gt;"Contact"&lt;/span&gt;, &lt;span class="str"&gt;"Contact"&lt;/span&gt;, &lt;span class="str"&gt;"Home"&lt;/span&gt;)&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
    &amp;lt;/nav&amp;gt;&lt;/pre&gt;
&lt;p&gt;The LI elements are formatted through the default site template and the UL is used as a wrapper to generate the menu at the top of the page. The ActionLink helper method renders an anchor tag for the specified controller/action.&lt;/p&gt;
&lt;h2&gt;Getting Some Data In There&lt;/h2&gt;
&lt;p&gt;Before I move onto the API portion of this exercise, I press F5 to run my site and use the newly created Phone Numbers menu to get at the UI the framework generated for me.&amp;nbsp; I add several entries as you can see below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_11.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_thumb_3.png" width="337" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, I want to go one step further. This is about accessing the data for a specific user, so I want to have some other data in there as well to prove out that we can isolate the data and make use of the Authentication providers in Asp.Net.&amp;nbsp; I create another user and add more entries as I did above, and you can see in the database now how there is data in there for two users.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_13.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_thumb_4.png" width="356" height="149" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I now have data specific to a couple of users and can build out the service piece.&lt;/p&gt;
&lt;h2&gt;Cutting a Web API Controller&lt;/h2&gt;
&lt;p&gt;This piece is really easy and uses the tooling and templates from the MVC Framework.&amp;nbsp; I add a new folder called Api to my Controllers folder and then right-click on the Api folder and select Add &amp;ndash;&amp;gt; Controller.&amp;nbsp; I name it PhoneNumberEntryController and select the Empty Api controller as the scaffolder. Even though it's the same name, it ends up in a different namespace so everyone's happy.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_15.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_thumb_5.png" width="240" height="96" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Much like the controller returning a view, I want the ApiController to only allow authenticated requests, and I want the method to return only phone numbers for the current user.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;    [Authorize]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; PhoneNumberEntryController : ApiController
    {
        &lt;span class="kwrd"&gt;private&lt;/span&gt; CloudyWebSiteContext db = &lt;span class="kwrd"&gt;new&lt;/span&gt; CloudyWebSiteContext();

        &lt;span class="kwrd"&gt;public&lt;/span&gt; ICollection&amp;lt;PhoneNumberEntry&amp;gt; Get()
        {
            &lt;span class="kwrd"&gt;string&lt;/span&gt; username = ControllerContext.Request.GetUserPrincipal().Identity.Name;

            var phoneNumbers = db.PhoneNumberEntries
                .Where(p =&amp;gt; p.UserName == username)
                .ToList();

            &lt;span class="kwrd"&gt;return&lt;/span&gt; phoneNumbers;

        }
    }&lt;/pre&gt;
&lt;p&gt;There's one more thing I want to do: I want to suppress the Xml formatter that is on by default in WebAPI.&amp;nbsp; By turning it off, the only remaining default serializer is Json.&amp;nbsp; Glenn Block &lt;a href="http://codebetter.com/glennblock/2012/02/26/disabling-the-xml-formatter-in-asp-net-web-apithe-easy-way-2/" target="_blank"&gt;shows us&lt;/a&gt; the most performant way to do this in our Global.asax's Application_Start menthod:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="csharpcode"&gt;GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;People. We are now awesomely rocking.&amp;nbsp; I will coin the term "awesrocking" because of the awesomeness here.&lt;/p&gt;
&lt;h2&gt;&lt;img style="background-image: none; margin: 0px 25px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" align="right" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/image_18.png" width="246" height="344" /&gt;Testing Out the Api&lt;/h2&gt;
&lt;p&gt;This is the part where I could start to hit some roadblocks if I didn't have the right tools. I love Fiddler and use it first whenever I'm, uh...fiddling around, but I can't use Fiddler to poke around the API because I &lt;em&gt;need&lt;/em&gt; a user to see what I'm doing and authentication is forms based in this context. I can't use IE efficiently because every time I get a Json document returned it prompts me to open the file of an unknown file type. I could use Notepad here (or a &lt;a href="http://stackoverflow.com/questions/2483771/how-can-i-convince-ie-to-simply-display-application-json-rather-than-offer-to-do" target="_blank"&gt;registry hack&lt;/a&gt;), I know, but it's a pain and I like to see my data all nicely formatted &lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Cloudy-With-a-Chance-of-Mobile-Building-_DC61/wlEmoticon-winkingsmile_2.png" /&gt;.&lt;/p&gt;
&lt;p&gt;FireFox to the rescue, along with a little helper plugin called JsonView.&amp;nbsp; In Visual Studio 11 this will be even easier because I can choose the browser to launch, rather than launching a separate browser or setting the OS default.&amp;nbsp; Regardless, I run the app in FireFox, log in to my site, then I hit http://127.0.0.1:81/api/phonenumberentry to see the data. JsonView takes over and I see my phone numbers as we expect.&lt;/p&gt;
&lt;p&gt;You can see the result in the image to the right.&lt;/p&gt;
&lt;h2&gt;Wrapping Up and Next Steps&lt;/h2&gt;
&lt;p&gt;Okay, here's the quick breakdown for the steps we have taken to this point:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Added our model (class)&lt;/li&gt;
&lt;li&gt;Added our data context&lt;/li&gt;
&lt;li&gt;Scaffolded our views&lt;/li&gt;
&lt;li&gt;Secured our views&lt;/li&gt;
&lt;li&gt;Tied the data entry and loading to specific users&lt;/li&gt;
&lt;li&gt;Added some data&lt;/li&gt;
&lt;li&gt;Created a Web API controller&lt;/li&gt;
&lt;li&gt;Secured the controller and started returning the correct data&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With these things in place, I can now start work on my phone client. Our project is already set, so we can get to the heavy lifting right away! Stay tuned for the next post where I'll get the phone client lined up to consume the data and display it.&amp;nbsp; Later on we'll talk about some things we can do to better improve the code and get us closer to best practices.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description><pubDate>Sun, 22 Apr 2012 03:19:36 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/cloudy-with-a-chance-of-mobile-building-our-data-model-amp-api</guid></item><item><title>Cloudy With a Chance of Mobile: Mvc Framework, Windows Azure and Windows Phone</title><link>http://www.jameschambers.com:80/blog/cloudy-with-a-chance-of-mobile-mvc-framework-windows-azure-and-windows-phone</link><description>&lt;p&gt;Interested in having a web site that supports user-specific data? Perfect, use Asp.Net and the built in membership providers. Want to put it in the cloud? Sweet, jump on the Azure bandwagon. Want to easily define your data model and store it?&amp;nbsp; No worries, EF Code First will make you cry, you love it so much. Want to access that data from Windows Phone? Well, my friend, you've come to the right place. I will take you from start-to-finish in creating an application that encompasses all of these pieces: &lt;/p&gt; &lt;ol&gt; &lt;li&gt;An Asp.Net Mvc 4 web site with a Web API controller to serve up some data. This data will be protected by the built-in Asp.Net membership providers.  &lt;li&gt;A local Service Deployment using the Windows Azure SDK.&amp;nbsp; This will be how we host the Mvc web site &amp;amp; Web API.  &lt;li&gt;A Windows Phone 7.1 client that accesses the protected data using the Asp.Net membership provider.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Getting Tooled Up&lt;/h2&gt; &lt;p&gt;We need to have the right kit in place to make this happen.&amp;nbsp; Please make sure you have the tools below if you want to follow along:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Visual Studio 2010 with &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=23691" target="_blank"&gt;SP1&lt;/a&gt; installed  &lt;li&gt;An internet connection.&amp;nbsp; Oh, wait...  &lt;li&gt;The &lt;a href="http://www.windowsazure.com/en-us/develop/net/" target="_blank"&gt;latest Azure bits&lt;/a&gt; downloaded and installed  &lt;li&gt;The Windows Phone 7.1 &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27570" target="_blank"&gt;SDK&lt;/a&gt; setup on your machine  &lt;li&gt;Laurent Bugnion's &lt;a href="http://mvvmlight.codeplex.com/" target="_blank"&gt;MVVM Light Toolkit&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Bootstrapping the Projects&lt;/h2&gt; &lt;p&gt;I use two instances of Visual Studio to develop in scenarios like this as we'll need elevated privileges to run the Compute Emulator for Windows Azure and I like to be able to leave my web project running while I work on my Windows Phone client application. &lt;/p&gt; &lt;p&gt;Launch the first IDE in &lt;em&gt;Adminstrative&lt;/em&gt; mode.&amp;nbsp; Create a new project from the "Cloud" templates and select Windows Azure Project.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/728684ba0d70_1428D/image_3.png" width="669" height="356"&gt;&lt;/p&gt; &lt;p&gt;Next, we're prompted to add our new role project, we'll select MVC 4:&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/728684ba0d70_1428D/image_12.png" width="332" height="211"&gt;&lt;/p&gt; &lt;p&gt;Finally, we'll pick Internet Application from the available templates in the Mvc 4 templates:&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/728684ba0d70_1428D/image_11.png" width="260" height="142"&gt;&lt;/p&gt; &lt;p&gt;Now, simply run the application by pressing F5.&amp;nbsp; Windows Azure needs a moment to start up, then you'll see the web site launch. Proceed to register in the site so that you have a valid log in. &lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/728684ba0d70_1428D/image_10.png" width="361" height="257"&gt;&lt;/p&gt; &lt;p&gt;Start your second IDE up, pick File –&amp;gt; New Project and navigate to the Silverlight for Windows Phone templates. Pick the vanilla Windows Phone Application project, and when you're prompted be sure to target Windows Phone 7.1.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/728684ba0d70_1428D/image_15.png" width="615" height="152"&gt;&lt;/p&gt; &lt;p&gt;You can quickly run your phone app to get your emulator running by pressing F5.&lt;/p&gt; &lt;h2&gt;Next Steps&lt;/h2&gt; &lt;p&gt;At this point, though we're not doing too much that is interesting, we have our two core projects up and ready to go. We created an Mvc 4 web role inside our Azure project and created a user account that we will late use to log in from the phone.&amp;nbsp; Next, we created the shell of our Windows Phone project that will hold a simple UI to display data that we load from the Mvc site.&amp;nbsp; With very little effort, we have our two major components in place and will be able to quickly advance our project.&lt;/p&gt; &lt;p&gt;Stay tuned for the next article where I will show you how to define a simple model and expose it via Web API.&lt;/p&gt;</description><pubDate>Sun, 22 Apr 2012 03:06:05 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/cloudy-with-a-chance-of-mobile-mvc-framework-windows-azure-and-windows-phone</guid></item><item><title>Automatic Generation of Metadata "Buddy" Classes</title><link>http://www.jameschambers.com:80/blog/automatic-generation-of-metadata-buddy-classes</link><description>&lt;p&gt;MvcScaffolding.EntityMetadata is &lt;a href="http://nuget.org/List/Packages/MvcScaffolding.EntityMetadata"&gt;now available on NuGet&lt;/a&gt;.&amp;nbsp; EntityMetadata generates metadata classes for you with attribute-based annotations to denote things like max length, human-readible display names, nullable fields and more.&amp;nbsp; These classes are used to decorate your entity with a MetadataType attribute, giving you great labels on your views with only a few extra keystrokes.&amp;nbsp; EntityMetadata gives you a custom scaffolder &amp;ndash; ControllerWithEntityMetadata &amp;ndash; to use and then calls the regular Controller scaffolder that you would normally call.&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-weight: bold;"&gt;How To Use It&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Here's a quick step-by-step to use EntityMetadata from a new Asp.Net MVC 3 project:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add an EDMX (an Entity Framework designer file) to your project and add a few tables&lt;/li&gt;
&lt;li&gt;Right-click on the diagram and select "Add Code Generation Item..."&lt;/li&gt;
&lt;li&gt;Select the "ADO.NET DbContext Generator" item from the Data category&lt;/li&gt;
&lt;li&gt;Build your project&lt;/li&gt;
&lt;li&gt;In the Package Manager Console, type: Install-Package MvcScaffolding.EntityMetadata. This will check for and/or pull down EF, T4 Scaffolding, MvcScaffolding and EntityMetadata itself&lt;/li&gt;
&lt;li&gt;Still in the Package Manager Console, type: &lt;strong&gt;Scaffold ControllerWithEntityMetadata &amp;ndash;Context YourContextNameHere&lt;/strong&gt; (obviously replacing the last bit there with your context name). EntityMetadata will prompt you for the rest!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you're having any issues, please see the FAQ at the bottom of this page, or visit the &lt;a href="http://jameschambers.com/EntityMetadata"&gt;project page here&lt;/a&gt; and post comments/questions.&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-weight: bold;"&gt;When To Use It&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Here's the scenario: You are using database-first development with the Entity Framework and would like to make use of MvcScaffolding.&amp;nbsp; You think the only hiccup in your journey is that MvcScaffolding isn't too fond of the context and classes that are generated for you.&amp;nbsp; Thankfully the Microsoft folks have taken care of the juicy bits for us and created the DbContext custom code template.&lt;/p&gt;
&lt;p&gt;All good, right?&lt;/p&gt;
&lt;p&gt;Except that all our views seem to be scaffolded in a not-so-human-friendly way and don't know anything about max length or required.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_14.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb_6.png" width="190" height="203" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The recommended way to fix this is to create a metadata class with all the same fields as your entity. You attribute each of these fields with the appropriate attributes from ComponentModel &amp;amp; DataAnnotations, setting up things like friendly names, whether or not fields are required and max length properties.&amp;nbsp; Finally, you create a partial class for your main entity and decorate it with the MetadataType attribute, specifying your metadata class.&lt;/p&gt;
&lt;p&gt;And you have to do this for each entity in your model.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;But we now have access to MvcScaffolding.EntityMetadata,&lt;/strong&gt; available through NuGet, so all you need to do is type (or use tab-completion to help):&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_12.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb_5.png" width="775" height="81" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;...and you'll see this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_2.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb.png" width="512" height="265" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;...and your view will look like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_4.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb_1.png" width="193" height="207" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;...and more importantly, you'll have a Metadata class (with the required partial for the main class) generated for you here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_8.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb_3.png" width="198" height="129" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;...which looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_10.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/image_thumb_4.png" width="285" height="374" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There are a few things to point out that make this worth considering:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;These are created on-demand and can be &lt;strong&gt;created inline when you're scaffolding controllers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;These are not overwritten&lt;/strong&gt; (unless you scaffold them again with &amp;ndash;Force)&lt;/li&gt;
&lt;li&gt;You are &lt;strong&gt;free to edit&lt;/strong&gt; this, rename, make changes as you see fit&lt;/li&gt;
&lt;li&gt;It's hella fast and &lt;strong&gt;takes the tediousness out&lt;/strong&gt; of having to create the 'buddy' classes for your entities&lt;/li&gt;
&lt;li&gt;You can call EntityMetadata &lt;strong&gt;even after you've scaffolded the view&lt;/strong&gt; and your view will immediately take advantage of the newly provided metadata.&lt;/li&gt;
&lt;li&gt;It does it's best to appropriately put human-friendly DisplayNames&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-weight: bold;"&gt;Here's the FAQs&lt;/span&gt;&lt;/h2&gt;
&lt;h3&gt;&lt;span style="font-weight: bold;"&gt;&lt;em&gt;I don't have this DbContext code generation item you're talking about. Where do I get it?&lt;/em&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Chances are you haven't installed the latest full bits of the Entity Framework, which you can get from &lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=26825"&gt;MSDN&lt;/a&gt;.&amp;nbsp; This installs the DbContext template, a much more POCO-ish code generator than the standard ObjectContext.&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;&lt;span style="font-weight: bold;"&gt;I'm getting errors about multiple primary keys with the same name. What is wrong?&lt;/span&gt;&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;Chances are the compiler's just got confused with a couple different versions of the same entity class name, like the one originally created with the ObjectContext on your Edmx.&amp;nbsp; Clean your solution and rebuild.&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;&lt;span style="font-weight: bold;"&gt;Is there a shorthand version so I don't have to follow the prompts?&lt;/span&gt;&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;Yes, just follow the same order as the prompts and you'll be fine (so, type Scaffold ControllerWithEntityMetadata YourDbmxFilename YourEntityname)&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;&lt;span style="font-weight: bold;"&gt;Why does my database appear to have no data in it when I know it does?&lt;/span&gt;&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;You didn't specify the &amp;ndash;Context argument to the scaffolder.&amp;nbsp; Check the instructions in the walkthrough up the page a bit.&amp;nbsp; Because EF 4.1 has code-first capabilities, and because MvcScaffolding will try to make up its own DB context, you've likely gone and created a new DB in either SqlCompact or SqlExpress on localhost.&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;&lt;span style="font-weight: bold;"&gt;Why can't it find my EDMX file?&lt;/span&gt;&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;Right now, EntityMetadata just assumes it's in your Models folder. Sorry, best I could do!&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;&lt;span style="font-weight: bold;"&gt;What if I need more help?&lt;/span&gt;&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;Please pop over to the &lt;a href="http://jameschambers.com/EntityMetadata"&gt;project page&lt;/a&gt; and ask questions/add comments/demand features. &lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Automatic-Generation-of-Metadata-Buddy-C_136D7/wlEmoticon-winkingsmile_2.png" /&gt;&lt;/p&gt;</description><pubDate>Thu, 19 Apr 2012 20:37:54 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/automatic-generation-of-metadata-buddy-classes</guid></item><item><title>Visual Studio 2010 Crashing on Uncompiled MVC 4 Projects</title><link>http://www.jameschambers.com:80/blog/visual-studio-2010-crashing-on-uncompiled-mvc-4-projects</link><description>&lt;p&gt;I have come across an issue where in MVC 4 pilot project, while working in views, the IDE would crash fairly frequently. I am using Visual Studio 2010 with SP1 and we are using GitHub for our source control.&amp;nbsp; Luckily I came across this article:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806"&gt;http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In the Known Issues and Breaking Changes section, it lists this gem:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;strong&gt;After installing ASP.NET MVC 4 Beta, the CSHTML/VBHTML editor in Visual Studio 2010 Service Pack 1 CSHTML/VBHTML editor may pause for a long time after typing snippet or JavaScript inside cshtml or vbhtml files.&lt;/strong&gt; This occurs only in ASP.NET MVC 4 applications which have just been created and have not yet been compiled. &lt;p&gt;The workaround is to compile the project to get the assemblies in the bin folder. Note, if you clean the project which removes the assemblies from the bin folder, the editor problem will come back. &lt;p&gt;This will be corrected in the next release.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;This was fairly similar to my case, but not entirely correct.&amp;nbsp; We are using NuGet package restore on our projects, and our .gitignore file is set up to exclude binaries.&amp;nbsp; So, even if you do compile the project, we’re not checking the bins into source control.&amp;nbsp; The IDE was crashing as though the project had never been build.&lt;/p&gt; &lt;p&gt;Thankfully the workaround still applies, and building the project after merging from upstream still did the trick.&lt;/p&gt;</description><pubDate>Mon, 16 Apr 2012 01:47:20 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/visual-studio-2010-crashing-on-uncompiled-mvc-4-projects</guid></item><item><title>Sharing With Friends - Opening up IIS Express To Other Team Members</title><link>http://www.jameschambers.com:80/blog/sharing-with-friends---opening-up-iis-express-to-other-team-members</link><description>&lt;blockquote&gt; &lt;p&gt;I'm developing an app with an Android-ian friend. When co-developing some of the features, we've found it critical to be able to easily access the development stream of the services, which I'm building with Asp.Net's WebAPI. Here's an easy way to configure your IIS Express instance to allow outside traffic.&lt;/p&gt;&lt;/blockquote&gt; &lt;h2&gt;Playing Inside the Sandbox&lt;/h2&gt; &lt;p&gt;The out-of-box experience for IIS Express is to have all web traffic closed to clients not residing on localhost. This is a great security practice, but not great when you're&lt;em&gt; trying&lt;/em&gt; to share a site or service.&amp;nbsp; Configuration of IIS Express is also non-evident; the little UI you do have exposes no way for you to actually modify the section of config that allows access.&lt;/p&gt; &lt;p&gt;To enable access outside your box, you need to create a virtual directory for your app and edit the applicationhost.config file located My Documents\IIS Express\config.&lt;/p&gt; &lt;p&gt;In Visual Studio, double-click on your project properties and open up the Web tab. Scroll down to the section where you can select the server and make sure it's on IIS Express. Finally, click on the Create Virtual Directory button. This creates an entry in the config file.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Sharing-With-Friends---Opening-up-IIS-Ex_1241D/image_5.png" width="520" height="212"&gt;&lt;/p&gt; &lt;p&gt;Now, open up that config file (again, it's in My Documents\IIS Express\config) and find your newly created site.&amp;nbsp; Update the config section so that it looks something the the following by adding a second binding. &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;site&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="MySiteOfAwesomeness"&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="13"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;application&lt;/span&gt; &lt;span class="attr"&gt;path&lt;/span&gt;&lt;span class="kwrd"&gt;="/"&lt;/span&gt; &lt;span class="attr"&gt;applicationPool&lt;/span&gt;&lt;span class="kwrd"&gt;="Clr4IntegratedAppPool"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;virtualDirectory&lt;/span&gt; &lt;span class="attr"&gt;path&lt;/span&gt;&lt;span class="kwrd"&gt;="/"&lt;/span&gt; &lt;span class="attr"&gt;physicalPath&lt;/span&gt;&lt;span class="kwrd"&gt;="C:\dev\MySiteOfAwesomeness\MySiteOfAwesomeness"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;application&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;bindings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;binding&lt;/span&gt; &lt;span class="attr"&gt;protocol&lt;/span&gt;&lt;span class="kwrd"&gt;="http"&lt;/span&gt; &lt;span class="attr"&gt;bindingInformation&lt;/span&gt;&lt;span class="kwrd"&gt;="*:4111:localhost"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;binding&lt;/span&gt; &lt;span class="attr"&gt;protocol&lt;/span&gt;&lt;span class="kwrd"&gt;="http"&lt;/span&gt; &lt;span class="attr"&gt;bindingInformation&lt;/span&gt;&lt;span class="kwrd"&gt;="*:4111:192.168.100.101"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;bindings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;site&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;Note that instead of localhost you can use your computer name or your IP address.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Finally, you're going to need to open up that port through whatever firewall you have.&amp;nbsp; For me, I used Windows Firewall with Advanced Security (much better than the Marginal Security version) and added a rule to allow traffic on my project's port.&lt;/p&gt;
&lt;p&gt;Hope this helps someone, and, hey, be nice to your Android friends, they might be somebody's brother.&lt;/p&gt;</description><pubDate>Fri, 13 Apr 2012 05:04:46 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/sharing-with-friends---opening-up-iis-express-to-other-team-members</guid></item><item><title>Clearing out the Stresses - Inbox 0, Me 1</title><link>http://www.jameschambers.com:80/blog/clearing-out-the-stresses-ndash-inbox-0-me-1</link><description>&lt;p&gt;I made huge inroads into de-cluttering my digital desktop today.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Clearing-out-the-Stresses_1466C/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Clearing-out-the-Stresses_1466C/image_thumb.png" width="457" height="109"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;That’s right, baby. Nothing in the inbox! I went from 2985 messages down to 0. Outlook loves me, so does my phone client. And I know exactly what I have left to deal with.&lt;/p&gt; &lt;h2&gt;Staying on Top of What To Do&lt;/h2&gt; &lt;p&gt;I have tried for the last 5+ months since coming on board at &lt;a href="http://twitter.com/logisense"&gt;LogiSense&lt;/a&gt; to use my Inbox as a staging area for the things that I have to do. The trouble is that as things can’t be immediately responded to, they start to build up. Miss a couple work days and look out, that beast grows quickly.&lt;/p&gt; &lt;p&gt;While watching &lt;a href="http://www.hanselman.com/blog/"&gt;Scott Hanselman&lt;/a&gt; present in the clip from &lt;a href="http://talks.webstock.org.nz/speakers/scott-hanselman/its-not-what-you-read-its-what-you-ignore/"&gt;WebStock12&lt;/a&gt; on how to filter out the noise, it was like a slap in the face when I realized how much weight this actually was.&amp;nbsp; &lt;em&gt;I have almost 3,000 things I need to deal with.&lt;/em&gt; It was a recurring, screaming thing in my head. I would make great gains, be –60 on the day or even better, but then be absent for two days and fall 100’s of messages further behind.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I kept thinking &lt;em&gt;I can never get back on top of this.&lt;/em&gt; And while I wouldn’t really call it beating myself up, I knew it was weighing on me.&amp;nbsp; &lt;/p&gt; &lt;p&gt;To get going, I started by creating a couple rules per Scott’s recommendation. I’m going to share the gist of this so that others can get ideas of how to sort their own and create the appropriate filters to clean out their inboxes. &lt;/p&gt; &lt;p&gt;The first rule to create was to filter out any email that wasn’t sent to me. I had one exception: if the email was addressed to a group that I am apart of (for example, &lt;a href="mailto:coworkers@myoffice.com"&gt;coworkers@myoffice.com&lt;/a&gt;) then leave it in my inbox.&amp;nbsp; Next, I created a filter where I was only a CC on the message and directed those to an Inbox – CC folder.&amp;nbsp; We have some automation accounts that send us notifications (failed builds, for example) so I created rules for those as well.&amp;nbsp; And finally, again per Scott’s suggestion, I created a rule that said anything from one of my bosses went into a golden folder for immediate undivided attention (my company recently started following me on Twitter, so it’s probably best I say something like that).&lt;/p&gt; &lt;h2&gt;Claiming Back my Inbox&lt;/h2&gt; &lt;p&gt;The last step was to run the rules against my inbox. I dropped to about 600 messages almost instantly. The scrollbar actually had context again, it actually meant something!&lt;/p&gt; &lt;p&gt;I then decided that anything that was older than 3 weeks was instantly on the chopping block. I moved all these “old” messages into an Inboxchive folder, then quickly ran a couple of searches over that folder for important messages or messages that relate to specific customers I’m working with. I threw those back into my inbox and marked everything else as read.&lt;/p&gt; &lt;p&gt;With 120 messages left I was easily able to sort things into the appropriate bins, flag them for follow-up if required, and respond to the ones I had yet to respond to.&amp;nbsp; It took about 45 minutes to do all this.&lt;/p&gt; &lt;p&gt;I feel like the self-perpetuated pressure of an inbox that has grown by about 125 messages per week is finally gone. Tonight, I am going to sleep better. I actually feel lighter.&lt;/p&gt; &lt;p&gt;Hope this helps and/or encourages someone out there there to clear a little clutter. &lt;/p&gt;</description><pubDate>Fri, 06 Apr 2012 03:38:56 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/clearing-out-the-stresses-ndash-inbox-0-me-1</guid></item><item><title>The Future of the Web on .NET Rocks!</title><link>http://www.jameschambers.com:80/blog/the-future-of-the-web-on-.net-rocks</link><description>&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/The-Future-of-the-Web-on-.NET-Rocks_12433/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/The-Future-of-the-Web-on-.NET-Rocks_12433/image_thumb.png" width="332" height="94"&gt;&lt;/a&gt;I recently spoke at Prairie Dev Con West in Calgary, where I was pleased to be asked to join a panel on the very popular internet audio talk show developers know as &lt;a href="http://www.dotnetrocks.com/" target="_blank"&gt;.NET Rocks&lt;/a&gt;!&amp;nbsp; Hosts Carl Franklin and Richard Campbell put together a panel to revisit a conversation they have every couple of years on "The Future of the Web".&lt;/p&gt; &lt;p&gt;The audio is now online, so &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=752" target="_blank"&gt;have a hear&lt;/a&gt;!&lt;/p&gt; &lt;p&gt;Joined by my friend &lt;a href="http://weblogs.asp.net/bsimser/" target="_blank"&gt;Bil Simser&lt;/a&gt;, fellow Canadian &lt;a href="http://vibrantcode.com/" target="_blank"&gt;Andrew Nurse&lt;/a&gt; from the Asp.Net team at Microsoft and &lt;a href="http://jameskovacs.com/" target="_blank"&gt;James Kovacs&lt;/a&gt; of JetBrains, it was a great group with diverse experience that allowed us to dive into all kinds of topics.&amp;nbsp; Starting with defining the current state of the web, we talked about current challenges, what the internet has become, and what the next few years holds for us as developers.&lt;/p&gt; &lt;p&gt;Be sure to check out the audio &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=752" target="_blank"&gt;here&lt;/a&gt; and be sure to subscribe to the show! &lt;/p&gt;</description><pubDate>Thu, 05 Apr 2012 00:55:11 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/the-future-of-the-web-on-.net-rocks</guid></item><item><title>Prairie Dev Con - Calgary Edition</title><link>http://www.jameschambers.com:80/blog/prairie-dev-con---calgary-edition</link><description>&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Getting-Connected--Attending-Conferences_8957/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Getting-Connected--Attending-Conferences_8957/image_thumb.png" width="661" height="241"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Look at all those hard-working developers!&lt;/p&gt; &lt;p&gt;Thanks to everyone who came out to my intro to MVC yesterday, and to the Dojo today.&amp;nbsp; I had a great time in the 2.5 hour Dojo session building the app with everyone who was able to attend.&amp;nbsp; We got to explore MVC, scaffolding, Models, Entity Framework + Code First, Controllers, Actions, jQuery, a bit of routing, partial views, packages in NuGet, HtmlHelpers and touched quickly on ActionFilters and even a bit of Areas.&amp;nbsp; Whew!&lt;/p&gt; &lt;h1&gt;Lessons Learned&lt;/h1&gt; &lt;p&gt;A big thanks goes out to the 30+ devs that came to the Dojo today...I certainly didn't anticipate the number of participants. With the myriad of OSes, Visual Studio editions and service pack levels, SQL Server configs and more, it was great to be able to work as a group through the things that came up and make the most of things, regardless of how well your tooling worked out.&amp;nbsp; For those who were unable to code through the exercises, I hope you took enough away from today to try some of these things on your own.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Here's some of my observations&lt;/strong&gt;:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;I &lt;em&gt;promise&lt;/em&gt; that if I am going to use someone else's jQuery plugin I won't go months without reviewing the syntax and configuration options!&lt;/li&gt; &lt;li&gt;I am moving this talk to MVC4 as we've now got a go-live licence. I will make this the requirement for the Dojo session and also will recommend VS2010 Ultimate, even the trial version, so that we're all working off the same kit.&lt;/li&gt; &lt;li&gt;For those that aren't able to get the software before the session (it is posted in the abstract!) I will make sure I download the full tools (and not just the downloader...#FAIL).&lt;/li&gt; &lt;li&gt;I will make sure we have the connection strings handy for a couple alternate SQL Server configs.&lt;/li&gt; &lt;li&gt;I will try to get a second projector in play – this will allow me to help work through issues that others might be having while still leaving the exercises up on the screen for those who wish to continue along.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Again, thanks to all who helped to work through the things that came up...great teamwork!&lt;/p&gt; &lt;h1&gt;Next Steps&lt;/h1&gt; &lt;p&gt;Don't stop now! Here's some things you can do to hone your skills and practice some of what we covered today:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Grab a copy of Visual Studio 2010 (the Ultimate trial if you don't have it already)&lt;/li&gt; &lt;li&gt;Download a copy of the MovieFu project from &lt;a href="https://github.com/MisterJames/MovieFu" target="_blank"&gt;GitHub&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Get in touch! Easiest is to reach me on &lt;a href="https://twitter.com/#!/CanadianJames" target="_blank"&gt;Twitter&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Start writing code! I &lt;em&gt;know&lt;/em&gt; that you got more out of the Dojo than you did out of the intro (if you attended that) because you &lt;em&gt;wrote code.&lt;/em&gt;&amp;nbsp; You don't need me there to do that! Cut a few projects and try to solve some simple scenarios, explore EF, areas or whatever interests you.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Good luck, and happy coding!&lt;/p&gt;</description><pubDate>Thu, 15 Mar 2012 04:45:04 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/prairie-dev-con---calgary-edition</guid></item><item><title>Okay Developers, Time to Level Up: Visual Studio 11 and Windows 8</title><link>http://www.jameschambers.com:80/blog/okay-developers-time-to-level-up-visual-studio-11-and-windows-8</link><description>&lt;p&gt;The bits are now in the wild.&amp;nbsp; I've got Win8 on the download and VS11 installed already on my Win7 boot.&amp;nbsp; I'll be wiping the Win8 partition and installing the Customer Preview of Win8 later today.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/Okay-Developers-Time-to-Level-Up-Visual-_822F/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Okay-Developers-Time-to-Level-Up-Visual-_822F/image_thumb.png" width="188" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h1&gt;&lt;/h1&gt; &lt;h1&gt;Bringing The Awesome&lt;/h1&gt; &lt;p&gt;I'll getting pumped for PrDC Calgary and I'm looking forward to rebuilding my MVC and NuGet talks on Windows 8 and Visual Studio 2011 for that conference. Only a couple weeks to go!&amp;nbsp; Remember, if you're hoping to come to the Dojo session for MVC, please bring along your laptop.&amp;nbsp; I'll be demoing some of the MVC4 bits, so please update your machines before you come (I'll have a few USB keys with the install if you don't have, but please make sure you have VS installed...even the free version).&lt;/p&gt; &lt;h1&gt;Getting Up To Speed&lt;/h1&gt; &lt;p&gt;Go grab all the bits for yourself:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://windows.microsoft.com/en-CA/windows-8/download" target="_blank"&gt;Windows 8 Consumer Preview&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank"&gt;Visual Studio 11 Beta&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description><pubDate>Wed, 29 Feb 2012 17:21:03 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/okay-developers-time-to-level-up-visual-studio-11-and-windows-8</guid></item><item><title>Continuous Communication: Bridging the Client and Server with SignalR</title><link>http://www.jameschambers.com:80/blog/continuous-communication-bridging-the-client-and-server-with-signalr</link><description>&lt;p&gt;&lt;strong&gt;&lt;font color="#333333"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font color="#333333"&gt;Have you ever tried to solve concurrency, or at least notification of concurrency threats? Have you worked out a way to keep data flowing between the client and the server? How about multiple client-side subscribers and the server? Server-to-client notification? And, if you have, were you able to make it easily available in other projects? Easily extensible?&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;If you’re a .NET developer, there’s no more guessing. SignalR is your new BFF.&lt;/p&gt; &lt;p&gt;It’s a new web, people.&amp;nbsp; We all know this. We don’t make “web pages” or even “web sites” any more. We make living, breathing applications. More and more, this also means a social aspect, and increasingly this means collaboration.&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;SignalR and the MVC Framework&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;It’s my thing. I spend most of my time in Asp.Net working with the MVC Framework, so my first question is, “Does it work with MVC?”.&amp;nbsp; Of course!&lt;/p&gt; &lt;p&gt;And it’s super simple:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;You’re going to &lt;strong&gt;create a project&lt;/strong&gt; &amp;amp; install SignalR via NuGet  &lt;li&gt;&lt;strong&gt;Build your backend&lt;/strong&gt; by creating one class that inherits from one of the SignalR base classes  &lt;li&gt;Finally, you need to &lt;strong&gt;wire up your view&lt;/strong&gt; by writing a tiny bit of script on the client&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;How does it work?&amp;nbsp; Crazy ninja magic. Covered with chocolate and ice cream.&amp;nbsp; Two scoops.&amp;nbsp; Let’s walk through a simple, but meaningful example (you can checkout the hello world on Github) and then revisit the interesting bits.&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;Creating the Project&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;Let’s start by creating a new MVC4 project (all the kids are doing it) in Visual Studio 2010. I’ve called mine Mvc.SignalR.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_3.png" width="446" height="282"&gt;&lt;/p&gt; &lt;p&gt;Next, we’re going to pick the empty template because we’re not too concerned about the whole flashy starter pages and default styling.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_5.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_thumb_1.png" width="356" height="320"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;And we’re off to the races!&amp;nbsp; Let’s drop into the package manager console and install SignalR. Type the following:&lt;/p&gt; &lt;p&gt;&lt;font size="3" face="Lucida Console"&gt;Install-Package SignalR&lt;/font&gt;&lt;/p&gt; &lt;p&gt;…and NuGet will do it’s magic for us, adding the required dependencies and updating our project accordingly.&amp;nbsp; What else is cool there?&amp;nbsp; Glad you asked!&amp;nbsp; NuGet also went ahead and updated any other libraries that SignalR takes a dependency on at a higher version. Sweet! Check out your console for all the details, that’s some great stuff there.&lt;/p&gt; &lt;p&gt;Next, we’re going to need a controller and a view so that we have something to see.&amp;nbsp; Right-click on your Controllers folder (in Solution Explorer) and click “Add –&amp;gt; Controller…” and create a new “HomeController”.&amp;nbsp; You’ll be taken to the class, at which point you can right click on the Index method and then select “Add View…”. Again, just create an empty view called Index.&amp;nbsp; Press F5 to run the app and you should see this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_thumb_2.png" width="307" height="251"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Not too much going on, but we’re just getting to the great stuff.&amp;nbsp; One more quick thing, we’re going to need it later, let’s stuff the client’s IP address into the ViewBag in our Index method of the HomeController.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_17.png" width="501" height="100"&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;Building the Backend&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;SignalR makes things super-easy for us to create the backend bits required for the continuous communication: we only need to inherit from a single class. What we’ll do in this sample is make a page visit counting mechanism that provides live updates to viewers of the page.&amp;nbsp; Original idea, and totally worth a patent. I’ll call it, “Analytics”. On we go.&lt;/p&gt; &lt;p&gt;The first bit is in creating a model class to record the visit. We’ll keep it simple and track only a few properties, but we’re going to take advantage of EF Code First to use as a data store. Create two classes in your Models folder, SiteVisit and SiteVisitContext.&amp;nbsp; Their implementations look like this:&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_10.png" width="329" height="101"&gt;&lt;/p&gt; &lt;p&gt;Note that inheriting from DbContext requires importing the System.Data.Entity namespace in the code below.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_thumb_3.png" width="400" height="87"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Poof! We have a database.&amp;nbsp; Next, I’ve got a simple class called UserLink where we provide the function that will be accessible from the client, through SignalR.&amp;nbsp; We inherit from Hub here to give us a whole bunch of “free” client-side goodness and make sure the SignalR bits know about us. Reflection is a beautiful thing.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_14.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_thumb_4.png" width="765" height="287"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;All I’m doing here is accepting an IP address, saving it to the SiteVisits table (that we created above through EF) and then getting a record count.&amp;nbsp; The interesting bit happens after we make that result message.&lt;/p&gt; &lt;p&gt;Clients is of type Dynamic.&amp;nbsp; There is no method on it called updateViewCount.&amp;nbsp; It doesn’t really know what I want to do, other than at runtime it’s going to have to go figure out where updateViewCount is and pass it my string.&amp;nbsp; Where does the method actually exist?&amp;nbsp; On the client, mes amis.&amp;nbsp; We’re writing that bad boy in JavaScript.&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;Wiring up the View&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;At this point, we need to make the client aware of the backend hub we’ve created. Open up _Layout.cshtml from Solution Explorer (it’ll be in your Views/Shared folder) and add a script reference to page. You’ll also need to update the reference to jQuery (remember how NuGet got us up-to-date?):&lt;/p&gt; &lt;p&gt;&lt;font face="Lucida Console"&gt;&amp;lt;script src="@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;&amp;lt;script src="@Url.Content("~/Scripts/jquery.signalR.js")" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;&amp;lt;script src="/signalr/hubs" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now, every page in our application (that uses this layout) will have access to SignalR.&lt;/p&gt; &lt;p&gt;“Wait a minute!”, says the observant, kung-fu yielding developer, “Script source is /signalr/hubs? But there’s no file that corresponds to that!” &lt;/p&gt; &lt;p&gt;Right you are, Darryl.&lt;/p&gt; &lt;p&gt;SignalR does this brilliant thing: it exposes your Hub classes through a route that it creates and initializes on your behalf. Your client is then able to access the methods of your class from JavaScript. It builds the library dynamically on the first call, caches it (until your application is recycled), and then takes care of resolving the calls for you.&lt;/p&gt; &lt;p&gt;Great, so our _Layout is updated to include the JavaScript bits we need, and SignalR is all up in our browser like a tree fort in a…tree.&amp;nbsp; So what do we need to do in our view?&amp;nbsp; Well, we want to have the IP address available from script, and we need a placeholder for our messages to come back to:&lt;/p&gt; &lt;p&gt;&lt;font face="Lucida Console"&gt;&amp;lt;input type="hidden" id="client-ip" value="@ViewBag.ClientIpAddress" /&amp;gt;&lt;br&gt;&amp;lt;div id="view-updates"&amp;gt;&amp;lt;/div&amp;gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Good, simple stuff.&amp;nbsp; Now the script.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_20.png" width="472" height="411"&gt;&lt;/p&gt; &lt;p&gt;I’m using jQuery (‘cause it’s awesome) to wire up an onload page handler and capturing the IP address from our hidden input (that we injected into our ViewBag in the controller). So far, so good.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Next we fetch our proxy to our hub dynamically through SignalR’s connection object, then use this proxy to wire up a callback. This is the method that will be executed from our Hub.&amp;nbsp; My handler simply takes a string and pushes it into a &amp;lt;p&amp;gt; tag.&amp;nbsp; Finally, we start the connection and pass in an anonymous function to be executed once SignalR is up and running.&amp;nbsp; This is where we make the call to our method in the hub.&amp;nbsp; So, to recap:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;We create a proxy  &lt;li&gt;We setup an event handler  &lt;li&gt;We startup the connection, and when complete, call our recordView method on the hub (I’ll get back to the timing of startup in a minute)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Sweet.&amp;nbsp; Hit F5, and see all your hard work come together…in fact, open a few browsers and watch as ALL the clients are updated when another loads.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/e4133c3ea69e_C1C6/image_23.png" width="621" height="431"&gt;&lt;/p&gt; &lt;p&gt;Hit refresh on any one of those to witness the awesomeness.&amp;nbsp; Nice work, fearless web developer!&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;Things I Learned Along the Way&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;If you start poking through the samples and venturing off to create new, more complex scenarios you may run into a couple things that aren’t at first apparent. I did, and hope that these points can help others who are looking.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Case Matters&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;Class names and function names in c# are converted to camel case on the client side. This is important to know because, for example, if you try to get a reference to the proxy/hub for your ClassName, it would have to be $.connection.className. Conversely, client-side event handlers aren’t converted to TitleCase, so if your function is functionName, you’re going to call functionName against the dynamic Clients object in your hub.  &lt;li&gt;If you don’t follow casing conventions, you’ll run into errors with SignalR:  &lt;ul&gt; &lt;li&gt;“Unable to set value of the property 'someCallBack': object is null or undefined” is likely a class case issue, happens when registering a callback in a SignalR hub.  &lt;li&gt;“Object doesn't support property or method 'YourMethod'” is likely an issue with case on a method in your hub, happens when you try to call the method after you’ve started the hub, and the JavaScript runtime is ouching because it can’t find the method in the proxy SignalR has generated.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;Wait for Startup to Finish&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;While this seems obvious, many of the samples I found used a button click handler to make a call into the hub, which allows for extra time for the script to finish starting up. I tried at first to invoke a method right after my call to $.connection.hub.start(). I got the following error:  &lt;ul&gt; &lt;li&gt;SignalR: Connection must be started before data can be sent. Call .start() before .send()&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;If you run into this scenario just use the method I coded above.&amp;nbsp; $.connection.hub.start() has an overload that accepts a callback as parameter, to be executed when the startup cycle is completed.&amp;nbsp; There is also an overload that accepts settings; you can view the client API &lt;a href="https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client"&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;Next Steps&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;Don’t stop here, you’ve got some ‘sperimenting to do!&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Make sure Visual Studio 2010 is up to date. If you don’t have a copy, get it here.  &lt;li&gt;Get to know your open source community projects.&amp;nbsp; Things like SignalR are helpful extensions to your projects and make development fun.&amp;nbsp; There are a ton of worthwhile projects that you should get to know., but reviewing the source can lead you in new directions as well.  &lt;li&gt;Get involved! Sure, you can use SignalR, but you can contribute as well.&amp;nbsp; Check out the project on &lt;a href="https://github.com/SignalR"&gt;GitHub&lt;/a&gt;, or if you have questions, pop into &lt;a href="http://jabbr.net/#/rooms/signalr"&gt;JabbR&lt;/a&gt; and connect with some of the helpful folks there.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;font style="font-weight: bold"&gt;A Quick Thanks&lt;/font&gt;&lt;/h2&gt; &lt;p&gt;I want to sent a quick thanks out to &lt;a href="http://twitter.com/kiliman"&gt;Michael Carter&lt;/a&gt; who helped through some timing and casing errors on JabbR while I put this sample together, David Fowler for sharing his excellent work on this project (the guy is absolutely brilliant) as well as &lt;a href="https://twitter.com/#!/stevelydford"&gt;Steve Lydford&lt;/a&gt; for the docs/samples he contributed to the project.&lt;/p&gt;</description><pubDate>Mon, 13 Feb 2012 19:15:35 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/continuous-communication-bridging-the-client-and-server-with-signalr</guid></item><item><title>Calling All Albertan Developers...PrDC is Approaching!</title><link>http://www.jameschambers.com:80/blog/calling-all-albertan-developers-prdc-is-approaching</link><description>&lt;p&gt;&lt;a href="http://www.prairiedevcon.com"&gt;&lt;img style="background-image: none; margin: 0px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" align="right" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/f339fdef32cd_8CDC/image_3.png" width="240" height="177" /&gt;&lt;/a&gt;I am excited to see the stars aligning for another round of Prairie Dev Con.&amp;nbsp; This will be my third time speaking at PrDC and my first time in Calgary, where I worked for the better part of six years.&amp;nbsp; I&amp;rsquo;m looking forward to getting back there&amp;hellip;I can hear the mountains calling!&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a great mix of sessions covering a variety of topics.&amp;nbsp; Some heavyweights from Microsoft are going to be there, delivering over 30 sessions on MS technologies.&amp;nbsp; There&amp;rsquo;s also a ton of great speakers covering agile, data, patterns and newer trends such as NoSQL.&amp;nbsp; Calgary local &lt;a href="https://twitter.com/#!/stimms"&gt;Simon Timms&lt;/a&gt; will even run you through what it takes to &lt;span style="text-decoration: line-through;"&gt;hack&lt;/span&gt; leverage phone systems in interesting ways.&amp;nbsp; Interested in Windows Phone development?&amp;nbsp; The one-and-only &lt;a href="https://twitter.com/#!/bsimser"&gt;Bil Simser&lt;/a&gt; will be on hand to walk you through from project start to phone deployment.&lt;/p&gt;
&lt;p&gt;Myself, I&amp;rsquo;ll be covering application development on the ASP.NET MVC framework.&amp;nbsp; I&amp;rsquo;m doing an intro session that is a 65 minute wild ride through a project, as well as a Dojo-style 2 hour marathon for which you&amp;rsquo;ll need to prove yourself as a developer by writing code.&amp;nbsp; &lt;strong&gt;Bring your laptop&lt;/strong&gt;!&lt;/p&gt;
&lt;p&gt;Registration is still open&amp;hellip;head over to &lt;a href="http://www.prairiedevcon.com"&gt;http://www.prairiedevcon.com&lt;/a&gt; for more information!&lt;/p&gt;</description><pubDate>Sat, 21 Jan 2012 15:29:31 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/calling-all-albertan-developers-prdc-is-approaching</guid></item><item><title>Asp.Net MVC / Ruby on Rails SMACKDOWN!</title><link>http://www.jameschambers.com:80/blog/asp.net-mvc-ruby-on-rails-smackdown</link><description>&lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/371e8bfdc521_A848/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/371e8bfdc521_A848/image_thumb.png" width="807" height="295"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Bring on the Carnage!&lt;/h2&gt; &lt;p&gt;Get ready, Manitoba, for the web technology smackdown of the year!&amp;nbsp; Think you're the &lt;em&gt;M&lt;/em&gt;ost &lt;em&gt;V&lt;/em&gt;aluable &lt;em&gt;C&lt;/em&gt;oder?&amp;nbsp; Perhaps you're projects are always on &lt;em&gt;track&lt;/em&gt;? We're putting your toolkit to the test!&lt;/p&gt; &lt;p&gt;On &lt;strong&gt;January 25, 2012 at 5:30pm&lt;/strong&gt;, the &lt;a href="http://www.winnipegdotnet.org/Home.aspx" target="_blank"&gt;Winnipeg .Net User Group&lt;/a&gt; is hosting the ultimate smackdown: Asp.Net MVC is going toe-to-toe with Ruby on Rails. Mark the date on your calendar!&amp;nbsp; The event takes place at 100 One Research Road in SMARTPARK Event Centre on the University of Manitoba campus.&lt;/p&gt; &lt;p&gt;You can register online &lt;a href="http://mvc-ruby-smackdown.eventbrite.com" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;Who's Presenting&lt;/h2&gt; &lt;p&gt;&lt;a href="http://twitter.com/#!/CanadianJames" target="_blank"&gt;Yours truly&lt;/a&gt; will be filtering the action from the Asp.Net MVC corner, with &lt;a href="http://twitter.com/#!/marcjeanson" target="_blank"&gt;Marc Jeanson&lt;/a&gt; tossing gems from the Ruby side of the ring. The always entertaining, notepad loving &lt;a href="http://twitter.com/#!/abarylko" target="_blank"&gt;Amir Barylko&lt;/a&gt; will be keeping things from getting too out-of-hand as the pro-Ruby host who has a secret crush on c#.&lt;/p&gt; &lt;h2&gt;What to Expect&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Major features of each tech tool kit  &lt;li&gt;Duelling coders on separate projectors  &lt;li&gt;Bloodshed and bandaging  &lt;li&gt;A moderator walking you through the code as it's being written  &lt;li&gt;Wins and losses if you adopt one over the other  &lt;li&gt;Lots of tomatoes  &lt;li&gt;Controllers, actions, views, routes, filters, JSON, open source repository integration, deployment  &lt;li&gt;Seriously, tomatoes &lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Bring Your Discernment&lt;/h2&gt; &lt;p&gt;Yeah, we'll be bringing the smack talk, but we're bringing our brains, too.&amp;nbsp; We'll have the answers on hand to the questions you dream up.&amp;nbsp; Stick around afterwards for questions and most likely brew if this thing spills out onto the street!&lt;/p&gt;</description><pubDate>Mon, 09 Jan 2012 16:29:22 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/asp.net-mvc-ruby-on-rails-smackdown</guid></item><item><title>Them're Big Shoes To Fill</title><link>http://www.jameschambers.com:80/blog/them-re-big-shoes-to-fill</link><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="MvpBadge" border="0" alt="MvpBadge" align="right" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/b1ef7f7f1cab_E1BF/MvpBadge_3.png" width="108" height="169"&gt;&lt;/p&gt; &lt;p&gt;I woke up this morning – the first day of 2012 – and knew it was going to be a great year. The kids were playing together, actually getting along!, my beautiful wife had made me a fresh cup of joe, and after getting a good couple weeks of visiting in with friends and family over Christmas, I officially start my holidays tomorrow.&lt;/p&gt; &lt;p&gt;And then I checked my email.&lt;/p&gt; &lt;p&gt;I am very pleased to be recognized as an MVP by Microsoft in the area of ASP.NET.&amp;nbsp; &lt;/p&gt; &lt;p&gt;After completing my registration on the MVP site, I had a look around the list of community leaders already in the program for ASP.NET and realized I have a long way to go to consider myself peers with those folks.&amp;nbsp; I read a lot of their blogs and many of the folks on the list have – through their articles, conference sessions, blog posts and emails – helped me out of more than one pickle.&lt;/p&gt; &lt;p&gt;Thanks to my nominator as well as the MVP lead here in Canada, and to Microsoft for this award.&amp;nbsp; I look forward to another great year of working in the ASP.NET space!&lt;/p&gt;</description><pubDate>Sun, 01 Jan 2012 22:12:14 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/them-re-big-shoes-to-fill</guid></item><item><title>So, You Want to Speak JSON, eh?</title><link>http://www.jameschambers.com:80/blog/so-you-want-to-speak-json-eh</link><description>&lt;p&gt;I am actively developing on ASP.NET MVC 3 and that has proven very useful to me as I make the switch to developing for Windows Phone 7.&lt;/p&gt; &lt;p&gt;&lt;em&gt;What?&lt;/em&gt; you say &lt;em&gt;That doesn't make any sense!&lt;/em&gt;&lt;/p&gt; &lt;p&gt;To which I reply: embrace the cloud, homeboy.&amp;nbsp; &lt;/p&gt; &lt;h2&gt;Okay, Wait a Minute&lt;/h2&gt; &lt;p&gt;I know, I know, I just went from JSON to MVC 3 to Windows Phone 7 to the cloud. But, here's the thing: they're all complimentary. &lt;/p&gt; &lt;p&gt;If you're looking for the code that makes returning JSON pretty much a freebie, skip ahead. &lt;font face="Lucida Console"&gt;Else { BuckleUp(); }&lt;/font&gt;&lt;/p&gt; &lt;p&gt;ASP.NET MVC is great for working with JSON – it supports binding JSON to your model classes natively, even when you're dealing with complex mappings like collections of entities nested in other entities.&amp;nbsp; It's also trivial to return JSON encoded data from your model classes and the result types are native to the framework.&amp;nbsp; It gets even better with LINQ to JSON and the &lt;a href="http://json.codeplex.com/" target="_blank"&gt;Json.Net&lt;/a&gt; serialization library available on &lt;a href="http://nuget.org/packages/Newtonsoft.Json" target="_blank"&gt;NuGet&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;JSON is lightweight, so it makes it a great candidate for pushing data around in mobile scenarios.&amp;nbsp; If you want to work with anything other than Windows Phone 7 (what? why would you do that?!), then the freebies in the .NET world don't play so nicely and you'll want to jump on the JSON bandwagon.&amp;nbsp; Json.Net works on WP7 as well, so now you're covered for your soon-to-be-awesome Windows Phone app.&amp;nbsp; (By the way...go &lt;a href="http://www.developermovement.com/" target="_blank"&gt;join the movement&lt;/a&gt; and get a free Xbox, WP7, $500 and more &lt;a href="http://www.developermovement.com/" target="_blank"&gt;here&lt;/a&gt;, if you're Canadian...publish some apps!).&lt;/p&gt; &lt;p&gt;Where does the cloud come into this? Thought you'd never ask.&amp;nbsp; A refresh on the Azure toolkit earlier this year gave us MVC3 deployment templates, so pushing your app out on the web &lt;a href="http://www.asp.net/mvc/overview/deployment/walkthrough-hosting-an-aspnet-mvc-application-on-windows-azure" target="_blank"&gt;is simple&lt;/a&gt;. Find out more &lt;a href="http://blogs.msdn.com/b/cdndevs/p/canadadoesazure.aspx"&gt;http://blogs.msdn.com/b/cdndevs/p/canadadoesazure.aspx&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;Speaking JSON&lt;/h2&gt; &lt;p&gt;So, you're doing some MVC 3 dev, you (maybe) are hosting out in the cloud, and you want to knock off some low-hanging fruit to turn your controllers and actions into full-fledged JSON participants?&amp;nbsp; I was at a conference recently and saw how easy this was in Ruby on Rails, and figured there had to be a way to do this in MVC.&amp;nbsp; I didn't want to have to write new versions of all my actions just to respond with the &lt;em&gt;same&lt;/em&gt; data as JSON.&lt;/p&gt; &lt;p&gt;Turns out this is too easy, but first we need to understand a little bit about how controllers and actions work.&lt;/p&gt; &lt;p&gt;Incoming requests are handled by the routing framework for us.&amp;nbsp; A request coming in for Home/Index results in an instance of the HomeController getting created and then our Index action (method) being invoked.&amp;nbsp; But did you know that you have the chance to use ActionFilters?&amp;nbsp; If we create our own ActionFilter, we get the chance to modify the parameters coming into the action, we get access to the controller, the HttpContext and more.&amp;nbsp; &lt;/p&gt; &lt;p&gt;And that's just on the front end of execution. We get a chance to look at everything again – including the view data – on the back end of execution as well, meaning we can swap out our own result object.&amp;nbsp; Huzzah! We have a vector!&lt;/p&gt; &lt;h2&gt;Using the Vector&lt;/h2&gt; &lt;p&gt;Here's the plan:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Let the action execute&lt;/li&gt; &lt;li&gt;Check to see if the requesting party was looking for a JSON response, and, if they were,&lt;/li&gt; &lt;li&gt;Create a new JsonResult and push the model data from the action into it&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Seems simple enough, right? Here's what the implementation looks like (and honestly, there's as much commenting in there as code):&lt;/p&gt;&lt;pre&gt;namespace Json.ActionFilter
{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class SupportsJson : ActionFilterAttribute&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // we will use the framework default but allow users to override in the constructor&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private JsonRequestBehavior _jsonRequestBehavior = JsonRequestBehavior.DenyGet;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SupportsJson() {}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if you want to allow GET (lame!) then be my guest...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SupportsJson(JsonRequestBehavior behavior)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _jsonRequestBehavior = behavior;&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;&amp;nbsp; // this happens AFTER the action is executed and BEFORE the result is returned&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // so it's the perfect place to swap out the result object for our JSON one&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override void OnActionExecuted(ActionExecutedContext filterContext)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // capture the application types&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var applicationTypes = (filterContext.HttpContext.Request.AcceptTypes ?? new string[] {""});&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // check to see if json is in there&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (applicationTypes.Contains("application/json"))&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;&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; // swap out the result if they requested Json&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;&amp;nbsp; var model = filterContext.Controller.ViewData.Model;&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;&amp;nbsp; filterContext.Result = new JsonResult { Data = model, JsonRequestBehavior = _jsonRequestBehavior };&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/pre&gt;
&lt;p&gt;Bam! And just like that we have us some JSON capabilities!&lt;/p&gt;
&lt;h2&gt;Using the ActionFilter&lt;/h2&gt;
&lt;p&gt;Here's an existing ActionResult I have:&lt;/p&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public ActionResult FooCookies(string term)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PeopleRepository repository = new PeopleRepository();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var people = repository.GetPeople(term);&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 View(people);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;p&gt;How much work is it to have it return JSON instead?&lt;/p&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [SupportsJson]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public ActionResult FooCookies(string term)&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PeopleRepository repository = new PeopleRepository();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var people = repository.GetPeople(term);&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 View(people);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;p&gt;Tada! That's right, just add the attribute &lt;font face="Lucida Console"&gt;SupportsJson&lt;/font&gt; and instantly you can repurpose any action to return JSON from the controller.&lt;/p&gt;
&lt;h2&gt;Next Steps&lt;/h2&gt;
&lt;p&gt;Hey look, you don't need to be building Windows Phone 7 apps on Azure to take advantage of this.&amp;nbsp; If you're building any site using jQuery or jQuery UI, if you work with other mobile platforms or even building for Windows 8, now is a good time to make sure that your data (and complex entity collections) are JSONable. So, you can start by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font size="4"&gt;Learning more about &lt;/font&gt;&lt;a href="http://www.asp.net/mvc" target="_blank"&gt;&lt;font size="4"&gt;ASP.NET MVC&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="4"&gt;Experimenting with &lt;/font&gt;&lt;a href="http://jquery.com/" target="_blank"&gt;&lt;font size="4"&gt;jQuery&lt;/font&gt;&lt;/a&gt;&lt;font size="4"&gt; and &lt;/font&gt;&lt;a href="http://www.jqueryui.com" target="_blank"&gt;&lt;font size="4"&gt;jQuery UI&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="4"&gt;Check out Json.Net on &lt;/font&gt;&lt;a href="http://json.codeplex.com/" target="_blank"&gt;&lt;font size="4"&gt;CodePlex&lt;/font&gt;&lt;/a&gt;&lt;font size="4"&gt; and &lt;/font&gt;&lt;a href="http://nuget.org/packages/Newtonsoft.Json" target="_blank"&gt;&lt;font size="4"&gt;NuGet&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="4"&gt;Trying out the &lt;/font&gt;&lt;a href="http://create.msdn.com/en-ca/" target="_blank"&gt;&lt;font size="4"&gt;Windows Phone 7&lt;/font&gt;&lt;/a&gt;&lt;font size="4"&gt; or &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/cdndevs/p/canadadoesazure.aspx" target="_blank"&gt;&lt;font size="4"&gt;Azure&lt;/font&gt;&lt;/a&gt;&lt;font size="4"&gt; toolkits&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br&gt;Good luck!&lt;/p&gt;</description><pubDate>Thu, 22 Dec 2011 02:01:55 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/so-you-want-to-speak-json-eh</guid></item><item><title>Ninjas Unleashed to the Wild</title><link>http://www.jameschambers.com:80/blog/ninjas-unleashed-to-the-wild</link><description>&lt;p&gt;I want to extend a huge thank you for all who attended my inaugural Asp.Net MVC3 Dojo event.&amp;nbsp; Over a dozen folks came out and slogged away at code as we worked through building a movie review site end-to-end using the MVC Framework, NuGet and one mighty fine IDE, Visual Studio 2010.&lt;/p&gt; &lt;p&gt;Some of the things we covered in today's two and a half hour code work-out:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Models, views and controllers (of course!)  &lt;li&gt;Scaffolding and the MvcScaffolding package  &lt;li&gt;jQuery and AJAX in MVC  &lt;li&gt;Partial views  &lt;li&gt;Action filters  &lt;li&gt;Authentication and Authorization  &lt;li&gt;The MVC tool chain  &lt;li&gt;NuGet and little "gems" like jQuery.RateIt and MvcMembership.Mvc  &lt;li&gt;Customizing the output of the scaffolders  &lt;li&gt;EF Code First, data contexts and dbsets  &lt;li&gt;Data annotations  &lt;li&gt;Model binding  &lt;li&gt;JSON and other alternate action return types  &lt;li&gt;...and more &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;We covered a lot of ground, for sure.&amp;nbsp; If you want to have at the reference app with the rest of the code that we weren't quite able to get to, please pop on over to &lt;a href="https://github.com/MisterJames/MovieFu" target="_blank"&gt;github&lt;/a&gt; and grab a copy of the solution.&lt;/p&gt; &lt;p&gt;Looking forward to hearing the feedback and please, feel free to get in touch.&lt;/p&gt; &lt;h1&gt;Next Steps&lt;/h1&gt; &lt;p&gt;Now that you've gone through File –&amp;gt; New Project, don't stop there.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Make sure you get your IDE up to date  &lt;li&gt;Keep exploring MVC, including MVC 4  &lt;li&gt;Ask questions...&lt;/li&gt; &lt;ul&gt; &lt;li&gt;On the &lt;a href="http://www.linkedin.com/groups/Canadian-Developer-Connection-3398140" target="_blank"&gt;Canadian Developer Connection&lt;/a&gt; (Linked In)...I keep watch here for web dev questions and am always happy to help out &lt;li&gt;Here, on my blog &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Ninjas-Unleashed-to-the-Wild_1378A/wlEmoticon-winkingsmile_2.png"&gt; &lt;li&gt;Ask on &lt;a href="http://www.twitter.com/canadianjames" target="_blank"&gt;Twitter&lt;/a&gt; with the #aspnetmvc hash tag &lt;li&gt;Or on a community site you're already comfortable with&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Have a good browse over at &lt;a href="http://nuget.org/" target="_blank"&gt;nuget.org&lt;/a&gt; and find packages that will simplify your development &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Thanks again!&lt;/p&gt;</description><pubDate>Wed, 23 Nov 2011 05:09:09 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/ninjas-unleashed-to-the-wild</guid></item><item><title>ASP.NET MVC 101/WPG</title><link>http://www.jameschambers.com:80/blog/asp.net-mvc-101-wpg</link><description>&lt;p&gt;It's great to be speaking in my stomping grounds and to be able to share a little about the ASP.NET MVC Framework while I'm here at Prairie Dev Con 2011 Winnipeg.&amp;nbsp; &lt;/p&gt; &lt;h1&gt;Surviving the Boom!&lt;/h1&gt; &lt;p&gt;Yikes. Talk about a presenter's nightmare! In the &lt;a href="http://www.irongeek.com/i.php?page=reviews/dell-xp-mini-displayport-projector-fix" target="_blank"&gt;perfect storm of technology fail&lt;/a&gt;, my particular combination of laptop make and model, the Apple mini-displayport adapter and a wonky projector worked together to try to stop the presentation from happening at all.&lt;/p&gt; &lt;p&gt;Thanks especially to D'Arcy Lussier for making a last minute schedule change and squeezing me back in.&amp;nbsp; There were about 50 people on board for the session with great questions and lots of interest.&amp;nbsp; Please keep the feedback coming and stay tuned for lots more info on MVC 4 here in my scratching grounds.&lt;/p&gt; &lt;p&gt;As for diving deeper, join me tomorrow for a two-hour Dojo-style dive into MVC3 and we'll get your feet wet.&amp;nbsp; Bring your laptops!&lt;/p&gt; &lt;p&gt;Here's a couple of links for you to help transition from what we talked about today in session to your own projects in your IDE:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://jameschambers.com/blog/best-links-to-getting-started-in-asp.net-mvc3" target="_blank"&gt;MVC "Getting Started" Best Links&lt;/a&gt;  &lt;li&gt;&lt;a href="http://jameschambers.com/blog/questions-about-the-asp.net-mvc-3-framework" target="_blank"&gt;Common Questions on MVC3 Development&lt;/a&gt;  &lt;li&gt;&lt;a href="http://jameschambers.com/blog/current-development-must-haves-for-asp.net-mvc-3" target="_blank"&gt;Must-Have Dev Tools for ASP.NET MVC3 Developers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Thanks again everyone for joining me and I look forward to seeing you at the Dojo session tomorrow.&lt;/p&gt;</description><pubDate>Tue, 22 Nov 2011 05:44:43 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/asp.net-mvc-101-wpg</guid></item><item><title>Prairie Dev Con - The Windows Phone 7 Conference App</title><link>http://www.jameschambers.com:80/blog/prairie-dev-con-ndash-the-windows-phone-7-conference-app</link><description>&lt;p&gt;I have published my version of the &lt;a href="http://www.prairiedevcon.com"&gt;Prairie Dev Con&lt;/a&gt; conference app out to the Windows Phone Marketplace, which you can browse or invoke an install from &lt;a href="http://www.windowsphone.com/en-US/apps/8e74279f-c4ab-43a6-bff3-a1a4ba1a8514"&gt;here&lt;/a&gt;. I am going to write a little at a high level about the experience, then get into some meatier posts down the road.&lt;/p&gt;
&lt;p&gt;Timeline&lt;/p&gt;
&lt;p&gt;It took ten days to build. Actually, it was more like two flights, a few hours in TO Pearson airport, one late night and an after-supper-code-crunch. I wish I had used some more agile tricks and principles to help pull through this project (some great conversations with &lt;a href="http://twitter.com/#!/srogalsky"&gt;Steve&lt;/a&gt; and &lt;a href="http://twitter.com/#!/davidalpert"&gt;David&lt;/a&gt; over the last few months about Agile have been a solid influence).&amp;nbsp; It certainly helped that &lt;a href="http://twitter.com/#!/davidalpert"&gt;David&lt;/a&gt; and &lt;a href="http://twitter.com/#!/abarylko"&gt;Amir&lt;/a&gt; had already built the JSON services, so my responsibilities were simply in being a consumer.&lt;/p&gt;
&lt;h1&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" border="0" alt="image" align="right" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Prairie-Dev-Con--The-Windows-Phone-7-Con_871C/image_3.png" width="294" height="477" /&gt;The Tech That Made it Tick&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;MVVM Light Toolkit &amp;ndash; this was a God-send. Seriously, it made visual binding in Expression Blend so easy. I put my time in the trenches hand-bombing XAML in the past. I think everyone should know XAML inside and out if you want to build WP7 apps, but once you do...man alive. Laurent, I'm buying you a drink!&lt;/li&gt;
&lt;li&gt;Silverlight Toolkit for Windows Phone &amp;ndash; This gem adds a bunch of controls to the designer's tool chest.&amp;nbsp; I made use of the page transitions and the hub tiles. I wasn't able to get a good thing going with the context menu - I was trying to use it on data-bound items and there was too much friction there to use it without pain.&lt;/li&gt;
&lt;li&gt;SQL CE and LINQ &amp;ndash; Yum. Though I had a few struggles with many-to-many relationships (I'll explain later) this makes working with relational data so simple. I was going to go with custom serialization but at the last minute threw together a spike solution and committed.&amp;nbsp; It was also good to exercise some of the Mango functionality.&lt;/li&gt;
&lt;li&gt;JSON.net &amp;ndash; This little library chews through JSON data and does an excellent job of deserialization without object mapping.&lt;/li&gt;
&lt;li&gt;Visual Studio 2010 &amp;ndash; Best development environment on the planet. Period.&lt;/li&gt;
&lt;li&gt;Expression Blend &amp;ndash; As I mentioned, I've earned my stripes in raw XAML, so I have no problem using the right tool for the right job. While the markup it creates is still a little verbose (and you have to cajole it into using best practices) Expression Blend makes such quick work of templating, databinding and making your app look like a big bowl of awesomesauce. With cherries.&lt;/li&gt;
&lt;li&gt;Marketplace Test Kit &amp;ndash; this is a handy utility that plugs into VS2010 when you install the phone SDK. It has some automated tests, makes sure your images are in check, then gives you the skinny on what you need to do to get your app approved.&amp;nbsp; This is the kind of &lt;em&gt;brutal transparency &lt;/em&gt;that app developers deserve and other vendors (*cough* Apple *cough*) would do good to imitate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This was a fun app to build. I got to touch (and dive into) a good variety of technical elements. I'm a little sick in the head, in that I like when things break. I tend to find that when they do break you get that exciting rush of running down the rabbit hole to see what makes things tick.&lt;/p&gt;
&lt;h1&gt;Friction Points &amp;ndash; Things I Don't/Didn't Like&lt;/h1&gt;
&lt;h2&gt;Navigation and User Experience&lt;/h2&gt;
&lt;p&gt;The back stack of NavigationService helps to maintain a consistent feel across the whole UI, across the whole phone. Microsoft is fighting for this, recommending this and I agree with it for the most part. In my app, though, I ran into this UX problem; consider the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;User clicks on the speakers tile&lt;/li&gt;
&lt;li&gt;They click on a speaker&lt;/li&gt;
&lt;li&gt;They click on a session&lt;/li&gt;
&lt;li&gt;They save the session (which navigates to the sessions page again)&lt;/li&gt;
&lt;li&gt;They go to another session&lt;/li&gt;
&lt;li&gt;They click back (which returns them to the session list)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;Now, to get to the "home" screen, they still have to click back 4 times.&amp;nbsp; Which is gross.&amp;nbsp; I "solved" this by adding a "return" button in the application bar of the session list, but I want to study this more and see if it's a design problem.&amp;nbsp; The thing is, until you want to move backwards, the app seems easy and fluid to move through speakers and sessions and I don't want to break that.&lt;/p&gt;
&lt;h2&gt;Many-to-Many Relationships in SQL CE&lt;/h2&gt;
&lt;p&gt;Another hang up (for a couple hours, on the plane with no internet access, boo!) was with the many-to-many relationships in SQL CE. I have "sessions" and "tags". Tags have several different sessions and sessions can have more than one tag.&amp;nbsp; In the mobile version of code-first, you have to be more explicit about these relationships, something I missed originally.&amp;nbsp; I'll put a post together on this.&lt;/p&gt;
&lt;h2&gt;Blend and Build Configurations&lt;/h2&gt;
&lt;p&gt;This one is completely obvious once you get what's going on, yet will make you pull out your hair if you don't. And I don't have a lot of hair to begin with.&lt;/p&gt;
&lt;p&gt;I was switching between Release, Debug and a config I created called "Trial".&amp;nbsp; Once you get in the pattern of flowing back and forth between VS 2010 and Blend, you have to remember that Blend only reads from your Debug directory. For example, if you're building in Release config changing parts of your ViewModel in VS and then flipping over to Blend to wire up the UI, the changes just don't show up when you're trying to bind.&amp;nbsp; Just be aware of this, if you're using multiple build configurations.&lt;/p&gt;
&lt;p&gt;Again, completely obvious, just not at 2 in the morning.&lt;/p&gt;
&lt;h2&gt;My Own Threading Design&lt;/h2&gt;
&lt;p&gt;I rushed this piece and didn't think this through. As a result, I had to create a bunch of events rather than using existing messaging facilities and even then, I didn't get the UI responsive. I'm redesigning this piece.&lt;/p&gt;
&lt;h1&gt;Awesomeness &amp;ndash; Things that Worked Really Well&lt;/h1&gt;
&lt;h2&gt;MVVM Light Toolkit and Expression Blend&lt;/h2&gt;
&lt;p&gt;I can't stress enough how quickly things come together when you're using "Blendable" view models.&amp;nbsp; This app was very much an experiment as to where those pieces fit and where code should live (as evidenced in the source), but visualizing data is just so easy with this marriage.&lt;/p&gt;
&lt;h2&gt;JSON.Net&lt;/h2&gt;
&lt;p&gt;While I originally missed the LINQ-to-JSON support, I've started playing with this and it's great. In my current build I had to smack together a bunch of DTO objects that could easily be used by JSON.Net, then I crafted up my real model objects and did a mapping.&amp;nbsp; I know now about the LINQ support and will be using that to replace my hackiness in my psuedo-DAL&lt;/p&gt;
&lt;h2&gt;Visual Studio 2010 and the Mango SDK&lt;/h2&gt;
&lt;p&gt;Folks, if you're developing on any other mobile platform, your tools aren't as good. I don't rightly care if that offends you. I've used the iOS and Android toolset (even with folks more well versed than I) and they've not shown me a better end-to-end experience. I've put up a challenge on Twitter for Android developers to do a head-to-head tool comparison at a conference with no bites.&amp;nbsp; I'm talking everything from New Project to the emulator all the way through to the Marketplace Readiness test kit.&amp;nbsp; It's all there, and I can effortlessly switch between Blend and VS.&amp;nbsp; The SDK is strong, close to the metal, and fully integrated into Visual Studio. It's what it should be.&lt;/p&gt;
&lt;h1&gt;And, The Project is Going Open Source!&lt;/h1&gt;
&lt;p&gt;That's right, even in it's half-baked bits right now, I'm pushing it up to Git.&amp;nbsp; &lt;a href="http://twitter.com/#!/abarylko"&gt;Amir&lt;/a&gt; has promised that the code will not be used to judge me &lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Prairie-Dev-Con--The-Windows-Phone-7-Con_871C/wlEmoticon-winkingsmile_2.png" /&gt; so I'm trusting that he'll hold true to that. There are no tests, the view models are inconsistent, I'm not making full use of the JSON tools and my templates are crafted quite differently from one view to the next.&amp;nbsp; Simply put: This code will not appear in it's current form on my resume &lt;img style="border-style: none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/Prairie-Dev-Con--The-Windows-Phone-7-Con_871C/wlEmoticon-winkingsmile_2.png" /&gt;.&lt;/p&gt;
&lt;h1&gt;And For You, the Reader&lt;/h1&gt;
&lt;p&gt;Well, surf over &lt;a href="http://www.windowsphone.com/en-US/apps/8e74279f-c4ab-43a6-bff3-a1a4ba1a8514"&gt;here&lt;/a&gt; and try it out! I would love feedback on what conference attendees would like to see in an app.&lt;/p&gt;
&lt;p&gt;Equip yourself with &lt;a href="http://create.msdn.com/en-ca/home/getting_started"&gt;the dev tools&lt;/a&gt; from MSDN.&lt;/p&gt;
&lt;p&gt;Familiarize yourself with &lt;a href="http://www.json.org/"&gt;JSON&lt;/a&gt;.&amp;nbsp; Grab a copy of &lt;a href="http://json.codeplex.com/"&gt;JSON.NET&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And start building apps!&lt;/p&gt;</description><pubDate>Tue, 15 Nov 2011 17:36:30 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/prairie-dev-con-ndash-the-windows-phone-7-conference-app</guid></item><item><title>Errors With AdControl in Windows Phone 7.1 (Retail 7.5)</title><link>http://www.jameschambers.com:80/blog/errors-with-adcontrol-in-windows-phone-7.1-retail-7.5</link><description>&lt;p&gt;I recently implemented the AdControl in the trial version of an app I've got in the marketplace. It is remarkable how easy they've made it to add ads to your app, with the Microsoft Advertising ASK baked right into the Windows Phone 7.1 SDK.&lt;/p&gt; &lt;p&gt;Unfortunately, I couldn't get the app displaying ads. I assumed there was something wrong with the way that I was implementing it, sent a couple emails out and went about finishing the other features I was working on. The error I was getting was:&lt;/p&gt; &lt;blockquote&gt; &lt;p align="left"&gt;A first chance exception of type 'Microsoft.Advertising.Mobile.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;No detail, wrapping the control code I was using to add the control to the page with a try block produced no results, so I moved on.&amp;nbsp; Unfortunately, as the ad was not appearing, I forgot that I had stubbed it in and published the update to the marketplace.&amp;nbsp; Oops.&lt;/p&gt; &lt;p&gt;When I saw the update appear in the Marketplace, I installed the app and...there were the ads.&amp;nbsp; In the paid version.&amp;nbsp; Oops.&lt;/p&gt; &lt;h3&gt;Check Your Manifest at the Door&lt;/h3&gt; &lt;p&gt;Wait a minute! Everything I've read says that if you can't see ads in the debugger that the ads won't show up on the live app. So what gives?&lt;/p&gt; &lt;p&gt;In looking for help on the error, I hit the SDK documentation where I stumbled on the control's &lt;a href="http://msdn.microsoft.com/en-us/library/hh495454(v=MSADS.20).aspx"&gt;events&lt;/a&gt;, where I found the ErrorOccurred event.&amp;nbsp; This little beauty solved all my problems.&amp;nbsp; Subscribing to this event – as easy as &lt;font color="#666666" face="Lucida Console"&gt;yourAdControl.ErrorOccurred += [tab] [tab]&lt;/font&gt; – and checking the properties on the exception provided the details on my problem: I was missing the ID_CAP_IDENTITY_USER declaration in my application manifest.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jameschambers.com/Media/Default/Windows-Live-Writer/203c741d6e15_11BF2/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jameschambers.com/Media/Default/Windows-Live-Writer/203c741d6e15_11BF2/image_thumb.png" width="631" height="75"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;So Why Did It Work on the Live App?&lt;/h3&gt; &lt;p&gt;Ah, right...when you submit your app to the Marketplace, Microsoft kindly builds your manifest for you with all the correct capabilities.&amp;nbsp; If you have extras, they take them out. If you don't have the ones you need, they inject them.&lt;/p&gt; &lt;p&gt;So, when you accidently publish your app with the AdControl in it, but you're missing the capabilities from your manifest, fear not! The App Hub publishing process will take care of everything.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Just try to remember to avoid pushing out your app with ads in the paid version.&lt;/p&gt; &lt;h3&gt;Going Forward&lt;/h3&gt; &lt;p&gt;So, here's some things you should do when using the AdControl:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Familiarize yourself with SDK if you're wondering about monetizing your app.&amp;nbsp; It's super simple.&lt;/li&gt; &lt;li&gt;Make sure you're properly registered with Pub Center and follow the instructions they give.&amp;nbsp; It's straightforward.&lt;/li&gt; &lt;li&gt;Add an event handler to the AdControl.ErrorOccured event. If you run into any issues with the control, it'll set you straight.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Good luck!&lt;/p&gt;</description><pubDate>Tue, 08 Nov 2011 03:55:42 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/errors-with-adcontrol-in-windows-phone-7.1-retail-7.5</guid></item><item><title>CustomBinding on Service Reference Results in TransportBindingElement Error</title><link>http://www.jameschambers.com:80/blog/custombinding-on-service-reference-results-in-transportbindingelement-error</link><description>&lt;p&gt;I’m coding an ASP.NET MVC 3 web site in Visual Studio 2010.&amp;nbsp; I added a service reference to a SOAP 1.2 version of a web service and started updating my code (I was using a SOAP 1.1 endpoint previously).&lt;/p&gt; &lt;p&gt;Unfortunately the switchover wasn’t as clean as I had hoped. The first method I changed resulted in an error, even on a call that appeared identical to the previous version. The error message I received was:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;The CustomBinding on the ServiceEndpoint with contract 'SubscriberServices' lacks a TransportBindingElement.&amp;nbsp; Every binding must have at least one binding element that derives from TransportBindingElement&lt;/em&gt;.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;…which looked like this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_thumb.png" width="244" height="146"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;For the quick fix, head to the end of this article.&amp;nbsp; Keep reading if you want to know what’s going on.&lt;/p&gt; &lt;h3&gt;What Was Going On?&lt;/h3&gt; &lt;p&gt;The two things that gave me the strongest clues where “CustomBinding” and “TransportBindingElement”, but for different reasons.&amp;nbsp; CustomBinding was a little unexpected as the service was added via HTTP. I guess I always assumed that it would be using an HTTP binding? The other piece suggested a derivative of the TransportBindingElement, which according to &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.transportbindingelement.aspx"&gt;MSDN&lt;/a&gt; is an abstract base class.&lt;/p&gt; &lt;h3&gt;Off to Our Config File&lt;/h3&gt; &lt;p&gt;Actually, at this point, I wanted less noise, so I quickly created a console app and added references to both services.&amp;nbsp; The differences were, at this point, fairly obvious. The 1.1 version of the service &lt;em&gt;was&lt;/em&gt; using a basicHttpBinding element (which I was expecting), whereas the 1.2 service was using a custom binding:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_thumb_1.png" width="491" height="308"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;So, what we’re looking at is trying to get the custom binding to know which transport we want to use. This is something that is implicit in the basicHttpBinding but needs to be explicitly set for customBindings.&lt;/p&gt; &lt;h3&gt;The Fix&lt;/h3&gt; &lt;p&gt;Following the links on the TransportBindingElement will lead us to the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.httptransportbindingelement.aspx"&gt;httpTransportbindingElement&lt;/a&gt;, which has both code and config file samples.&amp;nbsp; Adding a short and simple section to the binding did the trick; all I needed was an httpTransport element in the customBinding\binding element. The updated config section looked like this with the MSDN sample config injected:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_thumb_3.png" width="463" height="204"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms405872.aspx"&gt;Further reading&lt;/a&gt; shows that all the properties set in the MSDN example are actually all defaults, which means that our httpTransport element can simply be reduced to a single, self-closing tag:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_10.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.jameschambers.com/Media/Default/Windows-Live-Writer/c2efd7958743_EA38/image_thumb_4.png" width="467" height="173"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Great!&lt;/p&gt; &lt;h3&gt;Quick Recap&lt;/h3&gt; &lt;p&gt;So, in short, if you’re using a SOAP 1.2 service reference, or any service reference that requires the use of a custom binding, make sure you’ve added a TransportBindingElement (such as httpTransport) to your config file or in your code.&lt;/p&gt;</description><pubDate>Thu, 13 Oct 2011 14:49:45 GMT</pubDate><guid isPermaLink="true">http://www.jameschambers.com:80/blog/custombinding-on-service-reference-results-in-transportbindingelement-error</guid></item></channel></rss>
