Seismic Shifts in Web Development
Not really. But then again really. What I mean is the role of the web developer is changing fast and it's only been in recent months that I've looked up from my keyboard to see how the ground has shifted substantially. Some developer friends and I have often joked that the back end -- the database, object-relational mapping, domain model, business logic, and the controllers for the UI -- take us about a fraction of the time it takes us to get the UI right. We will sit for hours just to get the HTML right, float div tags, give up and go with the table tag, try again, move on, and so on and on. And now with awesome tools like EF and LINQ it's a breeze to do the sort of plumbing work that used to take weeks. Continue reading...
Pattern Toolkit Builder (VSPAT)
A few days ago Jezz Santos at Microsoft Consulting announced the release of Pattern Toolkit Builder (VSPAT) for Visual Studio 2010. Why not VSPTB? I think PA originally stood for "pattern automation" and the marketing folks just haven't nailed this down yet. Anyway, this promises to be the sort of game changer I've been looking for in my organization. I remember the software factory idea that the P&P team worked on a few years ago. It sort of died on the vine. The idea with pattern automation or "software factories" is that a very senior developer can create interactive, prescriptive (or merely helpful), project templates that junior developers can use to get started on a new project. The toolkit lets you create guidance and proven patterns in the actual code that gets unpacked from the project template so that junior developers aren't faced with the "blank slate how-do-I-get-started" problem. Continue reading...
IncludeMetadataConvention Deprecated in EF 4.3
In an earlier blog post I showed how to remove the IncludeMetadataConvention convention from your DbContext configuration. This is necessary up through EF 4.2 to prevent model metadata changes from being written to the database, something you don't want for legacy systems. Beginning with EF 4.3 this pluggable convention has been deprecated. As posted on the ADO.NET team blog: Continue reading...
Entity Framework 5.0 Sneak Preview
In the upcoming EF 5.0 Microsoft has improved performance due mainly to caching of inline LINQ queries. The benchmarks are impressive: Continue reading...
Polling with Knockout, JQuery, AJAX, and MVC
Some colleagues and I have been taking a close look at Knockout, the javascript library that implements the MVVM pattern for rich client UI. Knockout takes advantage of the new custom data attributes (data-*) in HTML 5 to bind declaratively a javascript view model to UI elements. That's pretty cool. But even better, Knockout will update your UI automatically whenever the underlying view model changes. It does this when you declare your model as an observable: Continue reading...
ChannelFactory, IDisposable and Handling Faults
In my last post (Poor Man's Publish-Subscribe WCF Service) I used the ChannelFactory to build a communication channel that I could use to call a WCF service. There's something about that implementation that I wanted to explain in more detail. Notice the try-catch block surrounding the using statement: Continue reading...
Poor Man's Publish-Subscribe WCF Service
I'm going to describe a WCF implementation of a publish-subscribe pattern that is used here at a medium-sized organization where I'm a lead developer. For reasons I won't go into MSMQ and the cloud were not options for us. Yet we needed durability, reliability, and all of the goodness that comes with a service bus. So we rolled our own "poor man's" pub sub (or observer pattern) service a simplified version of which I'll describe here. Continue reading...
Snuggle up to jquery $.ajax
In an earlier post I described how to use the MVC 3 Ajax.ActionLink to post an async delete back to the server. Ajax.ActionLink depends upon jquery.unobtrusive-ajax.js, a script included with the MVC 3 project template. As Brad Wilson has blogged, and I demonstrated, you create an AjaxOptions class and pass it into the ActionLink method constructor. When the view is rendered those properties are emitted with the anchor tag as HTML 5 data-* attributes: Continue reading...
InvalidOperationException Using EF Code First
If you're using EF 4.1 "Code First" and make changes to your model you get the following error: Continue reading...
Taking Your Game to the Next Level: FluentValidation
This is the last in a three-part series on validation techniques in MVC 3. See the first post and the second post to get the solution set up. Continue reading...
Class-Level Validation in MVC 3 with IValidatableObject
In a previous post I covered simple and custom validators for model properties. Do read that post first to get a sample MVC 3 solution set up. Essentially at this point we have one out-of-the-box and one custom validator on our Widget class: Continue reading...
Simple and Custom Validation in MVC 3
This is the first of a series on validation and business rules in MVC 3. I'll start out simple and we'll work out way up to the more complex. I'm going to build on the solution created in the previous blog post (Delete Like a Rock Star) so go there and get set up. Continue reading...
Delete Like a Rock Star with MVC3, Ajax and jQuery
RSS
Sure you can be a chump and use the out-of-the-box delete functionality that the MvcScaffolding gives you. Or you can use a little jQuery and delete like a rock star. Get your project set up first. Create a new MVC3 web app in Visual Studio 2010. If you have SP1 you have a choice now: internet or intranet. I'll assume we're creating an internet app but it doesn't matter really. Next add a new model called Widget: Continue reading...
Render HTML for Menu in MVC 3 Using SiteMapProvider
There are several good jQuery menu plugins but I like the old skool ASP.NET SiteMapProvider because I can declare my app roles in there and get security trimming for free. Add and configure the default XmlSiteMapProvider or customize one to override the IsAccessibleToUser method. Your choice. Then add this MenuHelper static class to your project: public static class MenuHelper { public static MvcHtmlString Menu(this HtmlHelper helper) { var sb = new StringBuilder(); sb.Append("<ul id='nav'>"); // Render each top level node var topLevelNodes = SiteMap.RootNode.ChildNodes; foreach (SiteMapNode node in topLevelNodes) { sb.AppendLine("<li>"); sb.AppendFormat("<a href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title)); if (node.HasChildNodes) { sb.AppendLine("<ul>"); foreach (SiteMapNode childNode in node.ChildNodes) { sb.AppendLine("<li>"); sb.AppendFormat("<a href='{0}'>{1}</a>", childNode.Url, helper.Encode(childNode.Title)); sb.AppendLine("</li>"); } sb.AppendLine("</ul>"); } sb.AppendLine("</li>"); } // Close unordered list tag sb.Append("</ul>"); return new MvcHtmlString(sb.ToString()); } } If this is the first helper for the project then add the namespace where your MenuHelper class lives to your Views Web.config file: <system.web.webPages.razor> <host … Continue reading...
More Awesomeness: Post JSON to an Action Method
Fortunately I came late to the party and didn't develop MVC 2 web apps. I understand that back in those ancient days (about 6 months ago) you had to walk uphill both ways to post JSON data back to an action method. Phil Haack has a great blog post on the topic. Basically, you had to write a custom filter, register a JsonValueProviderFactory in application startup, and decorate your action method with the JSON serializer attributes. What a pain. In MVC 3 it's super easy to use AJAX to post JSON back to an action method. Here are the steps. Continue reading...
Implement jQuery FullCalendar Plugin in MVC 3
Let's implement Shaw's awesome FullCalendar jQuery plugin with an MVC 3 project. I'll assume you've downloaded the bits and have included the fullcalendar.min.js script in your project. Here I want to illustrate two things: (1) populating the calendar with events from the database; and (2) handling the calendar's dayClick event to create a new event. Continue reading...
TruthWidget Launch Part 2
TruthWidget.com is fully ported over to MVC 3 from Silverlight 4. I ran through all of my tests and so it's up and running live. The awesome part was being able to reuse Entity Framework 4 and the repository wrappers. I took the RIA web services and put them into MVC services. I've seen examples where the controller calls EF directly but that makes me uncomfortable so I wanted that additional layer of abstraction. The bulk of my work was throwing away the XAML and recreating Html (Razor) web pages. What I liked about my experience is how I can create HtmlHelpers (little helper methods that emit small chunks of HTML), partial views, and stitch them together to create the whole view. This enabled me to follow the DRY principle a lot more than in XAML where I tended to have big bloated views -- especially if I did it in Blend. I'm really happy with my experience. I'll blog on specific tips and tricks when I have time. For now I'll just say that everything just works in MVC 3. It's a real joy to work with it. Continue reading...
Silverlight Problems: Yet Another Plug In
So I labored mightily last December on TruthWidget.com. Wanting to be hip and happening I implemented it in Silverlight 4 and RIA Services. It worked out well. I was pumped. So post-launch I asked a few non-technical friends to take it out for a spin. And then the problems started. They told me it didn't work. I quickly discovered most didn't know that they needed to install the Silverlight runtime. I was counting on the blue box of joy to do the work for me but it wasn't explicit enough and many didn't even look at it very closely. So following Tim Heuer's lead I dove into a custom installation experience. But the detection script reports Chrome as an unsupported browser. I could hack the script of course. But the problem is much deeper: my friends didn't want to install yet another plug in. They didn't understand why they needed to do it, had questions about it, and finally hesitated to take the simple 30 seconds to do it. I realized that if this is how my friends reacted what would complete strangers do? In the end I decided I needed to port the app over to a web application. MVC 3 to be specific and it's going great. More on that later. My takeaway from this experience is if you cannot control the end user's browser then stick with tried and true web applications. If it's an intranet app where you know your end user's environment and they need a rich-client experience then consider Silverlight 4. Continue reading...
WCF Debugging Tip
WCF Debugging from Silverlight client-side: WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);Also, turn on debugging in the WCF service Web.config. You'll get detailed inner exception information. In the <serviceBehaviors> region: <serviceDebug includeExceptionDetailInFaults="true" /> Continue reading...
Active Directory Federation Services v2
ADFS is based on Web Services architecture (WS-* specifications) and conforms to industry standards and protocols. This release supports Azure and would be a great choice for enterprises using AD as a credential store on the local domain who want to migrate to the cloud. Applications hosted on local IIS7 servers as well as in the Azure cloud can take advantage of single sign on over the extranet for the duration of the user's browser session. See MSDN for developing federation-aware applications. Continue reading...

My name is James Still and I'm a seasoned software developer living and working in Oregon USA. I'm an avid cyclist, backpacker, reader, stargazer, and I pick at the guitar from time to time. 
