<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>RJYGRAHAM</title>
        <link>http://www.rjygraham.com/Default.aspx</link>
        <description>Confessions of a Chipotle fueled Software Engineer</description>
        <language>en-US</language>
        <copyright>Ryan Graham</copyright>
        <generator>Subtext Version 2.1.0.5</generator>
        <image>
            <title>RJYGRAHAM</title>
            <url>http://www.rjygraham.com/images/RSS2Image.gif</url>
            <link>http://www.rjygraham.com/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Using Facebook Connect with ASP.NET MVC and the Facebook Developer Toolkit 3</title>
            <category>MVC</category>
            <category>Facebook</category>
            <link>http://www.rjygraham.com/archive/2009/11/22/using-facebook-connect-with-aspnet-mvc-and-the-facebook-developer-toolkit-3.aspx</link>
            <description>&lt;p&gt;If you haven’t heard, Microsoft and Clarity Consulting have released version 3 of the &lt;a target="_blank" href="http://facebooktoolkit.codeplex.com/"&gt;Facebook Developer Toolkit&lt;/a&gt; (FDT). As described on the Codeplex home page the main goals for version 3 were:&lt;/p&gt;
&lt;p&gt;• &lt;strong&gt;Provide better doc and samples &lt;br /&gt;
&lt;/strong&gt;• Provide support for Silverlight &lt;br /&gt;
• Provide support for ASP.NET MVC &lt;br /&gt;
• Provide improved support for WPF &lt;br /&gt;
• Provide improved support for FBML (FBML Server Controls) &lt;br /&gt;
• Provide a login control that can be used to replace the BasePage and/or MasterPage for Canvas Development &lt;br /&gt;
• Improve out of the box support for Extended Permission Prompts &lt;br /&gt;
• Refactor core source to improve maintainability and design &lt;br /&gt;
• Fix known bugs&lt;/p&gt;
&lt;p&gt;Although several great examples are shipped with the latest version of FDT, none of them target authenticating users via Facebook Connect on ASP.NET MVC apps. Luckily, you’ll find that ASP.NET MVC apps aren’t all that different from Web Form apps in this regard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Goals&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;The goals of this contrived example are: &lt;/li&gt;
    &lt;li&gt;Host a “Connect with Facebook” button in the Index view of our HomeController. &lt;/li&gt;
    &lt;li&gt;Popup the Facebook Connect page when the button is clicked. &lt;/li&gt;
    &lt;li&gt;Upon successful login, redirect back to the AuthenticateFacebook action on the HomeController so we can verify the user is in fact logged in and grab some user info. &lt;/li&gt;
    &lt;li&gt;Redirect to the About view on the HomeController and display some personal information from Facebook Connect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Assumptions&lt;/h3&gt;
&lt;p&gt;Before we begin, I’m going to make the following assumptions:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;You’ve already created an ASP.NET MVC project with which you want to authenticate users via Facebook Connect &lt;/li&gt;
    &lt;li&gt;You’ve already &lt;a target="_blank" href="http://facebooktoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=35534"&gt;downloaded FDT 3&lt;/a&gt; and added a reference to Facebook.dll to your ASP.NET MVC project &lt;/li&gt;
    &lt;li&gt;You’ve already created a Facebook application using the &lt;a title="http://www.facebook.com/developers" href="http://www.facebook.com/developers"&gt;Developer application&lt;/a&gt; on Facebook.&lt;/li&gt;
    &lt;li&gt;You’ve made a note of your Facebook application’s API Key and Application Secret.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Index View&lt;/h3&gt;
&lt;p&gt;Setting up the Index view is a pretty trivial task. The first order of business is to add a reference to the Facebook JavaScript file. Simply add this to the &amp;lt;head&amp;gt;&amp;lt;/head&amp;gt; tag of your view (or most likely your master page):&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d8f24794-ec9c-4b2c-afd9-45bc29bff6f1" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;src&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="text/javascript"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The next thing we need to do is add the Facebook Connect button on the view:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:59089172-08b9-478f-b97f-a2e586d53773" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;a&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;title&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Facebook"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;href&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="#"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;onclick&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="FB.Connect.requireSession(function(){window.location='/Home/AuthenticateFacebook';}); return false;"&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;img&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;alt&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Connect with Facebook"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;src&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_large_long.gif"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;a&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Notice how the FB.Connect.requireSession accepts a function which is what happens upon a successful login by the user. In this instance we’re redirecting the browser to the AuthenticateFacebook action on the HomeController, but you can change this to whatever you like.&lt;/p&gt;
&lt;p&gt;The last thing we need to do is add the required FB.Init JavaScript call at the very bottom of our Index view:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bca3dfe7-1857-45a3-a102-c713b1926b38" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    FB.init('00000000000000000000000000000000', 'XdReceiver');&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As stated on the &lt;a target="_blank" href="http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Init"&gt;Facebook Developer Wiki&lt;/a&gt;, this call safely initializes the Facebook API for use on a Connect site or iframe application. The first parameter is your application’s API key, while the second URL of our cross domain communication channel file which we’ll be creating next.&lt;/p&gt;
&lt;h3&gt;XdReceiver&lt;/h3&gt;
&lt;p&gt;For security reasons, web browsers restrict web sites from making AJAX calls across domains. In general this is a very GOOD thing but can be a bit of  a headache when trying to integrate your site with an external site. Hoverever, there are ways around this – in Facebook’s case they use an iframe (i.e. XdReceiver). You can read all the gory details about it &lt;a target="_blank" href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Setting up our XdReceiver involves two simple steps. First, open up HomeController.cs and add the following action:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c5e04e4c-43f6-40ad-aa90-2c49561bac21" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ActionResult&lt;/span&gt; XdReceiver()&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; View();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Next, add a view named XdReceiver to the Home folder in your Views folder - be sure to uncheck the Select master page on the Add View dialog. Replace the entire contents of the view with the following: &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0e798641-379c-44b4-90cd-d0350c3e7d78" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;@&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;Page&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Language&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="C#"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Inherits&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Mvc.ViewPage"&lt;/span&gt; &lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;DOCTYPE&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;html&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;"-//W3C//DTD XHTML 1.0 Strict//EN"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;html&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://www.w3.org/1999/xhtml"&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;body&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;src&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="text/javascript"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;script&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;body&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;html&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;AuthenticateFacebook Action&lt;/h3&gt;
&lt;p&gt;Up until now we’ve been laying the foundation for our Facebook Connect application - now onto the good stuff! The AuthenticateFacebook action on the HomeController is where all the magic happens.&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:519b83ae-fc01-428f-bf1b-9557f8e69e57" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ActionResult&lt;/span&gt; AuthenticateFacebook()&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt;    &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #2b91af"&gt;ConnectSession&lt;/span&gt; _connectSession = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ConnectSession&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"00000000000000000000000000000000"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"00000000000000000000000000000000"&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!_connectSession.IsConnected())&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #008000"&gt;// The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #008000"&gt;// Authenticated, create API instance.&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #2b91af"&gt;Api&lt;/span&gt; _facebookAPI = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Api&lt;/span&gt;(_connectSession);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #008000"&gt;// Load user.&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #2b91af"&gt;user&lt;/span&gt; user = _facebookAPI.Users.GetInfo();&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; fullName = user.first_name + &lt;span style="COLOR: #a31515"&gt;" "&lt;/span&gt; + user.last_name;&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt; dob = &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.ParseExact(user.birthday, &lt;span style="COLOR: #a31515"&gt;@"MMMM d, yyyy"&lt;/span&gt;, System.Globalization.&lt;span style="COLOR: #2b91af"&gt;DateTimeFormatInfo&lt;/span&gt;.InvariantInfo);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;long&lt;/span&gt; userId = _connectSession.UserId;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        TempData[&lt;span style="COLOR: #a31515"&gt;"FullName"&lt;/span&gt;] = fullName;&lt;/li&gt;
    &lt;li&gt;        TempData[&lt;span style="COLOR: #a31515"&gt;"Dob"&lt;/span&gt;] = dob;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        TempData[&lt;span style="COLOR: #a31515"&gt;"UserId"&lt;/span&gt;] = userId;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; RedirectToAction(&lt;span style="COLOR: #a31515"&gt;"About"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"Home"&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; RedirectToAction(&lt;span style="COLOR: #a31515"&gt;"Index"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"Home"&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;/li&gt;
    &lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For the most part, the AuthenticateFacebook action is straight forward. We first create a ConnectSession using our API Key and Application Secret. If the user was successfully authenticated the session will be connected which means we can then create an instance of the Api and use that to access information about the user. In this case, we’re retrieving the user’s name, date of birth, and user id and then redirecting them to the About view on the HomeController.&lt;/p&gt;
&lt;h3&gt;About View&lt;/h3&gt;
&lt;p&gt;The about view simply displays the user’s name, date of birth, and user id that we stuffed into the TempData collection.&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0772e6df-eaca-489c-a5d8-a745a1dd678f" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;@&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;Page&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Language&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="C#"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;MasterPageFile&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="~/Views/Shared/Site.Master"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Inherits&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Mvc.ViewPage"&lt;/span&gt; &lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;asp&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="aboutTitle"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="TitleContent"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="server"&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    About Us&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;asp&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;asp&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="aboutContent"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MainContent"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="server"&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;p&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;=&lt;/span&gt;TempData[&lt;span style="COLOR: #a31515"&gt;"FullName"&lt;/span&gt;]&lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;, you were born on &lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;=&lt;/span&gt;TempData[&lt;span style="COLOR: #a31515"&gt;"Dob"&lt;/span&gt;]&lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt; and your Facebook user ID is: &lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;=&lt;/span&gt;TempData[&lt;span style="COLOR: #a31515"&gt;"UserId"&lt;/span&gt;]&lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;p&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;asp&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;:&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Hopefully this sample shows you just how easy it is to add Facebook Connect to your ASP.NET MVC. In a real world application you’ll probably want to create a user account in your site’s membership system (Membership Provider for instance) and then map the user’s Facebook Connect user id to your site’s user id.&lt;/p&gt;
&lt;p&gt;I’ve zipped up a sample which you can download here: &lt;a href="http://www.rjygraham.com/Attachments/MvcFBConnectSandbox.zip"&gt;MvcFBConnectSandbox.zip&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/14.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/11/22/using-facebook-connect-with-aspnet-mvc-and-the-facebook-developer-toolkit-3.aspx</guid>
            <pubDate>Sun, 22 Nov 2009 06:15:11 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/14.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/11/22/using-facebook-connect-with-aspnet-mvc-and-the-facebook-developer-toolkit-3.aspx#feedback</comments>
            <slash:comments>44</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/14.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Reusable, Maintainable, and Extensible WCF Security</title>
            <category>WCF</category>
            <category>Validation</category>
            <category>Silverlight</category>
            <link>http://www.rjygraham.com/archive/2009/10/22/reusable-maintainable-and-extensible-wcf-security.aspx</link>
            <description>&lt;p&gt;Lately I’ve been having a lot of fun architecting and developing a Silverlight project at work that uses WCF to communicate with a backend CMS system. One of the challenges however, was coming up with a reusable, maintainable, and extensible means of applying security to the WCF services. My solution just happens to be the topic of this post.&lt;/p&gt;
&lt;p&gt;Luckily, I stumbled upon a post by David Betz (&lt;a href="http://www.netfxharmonics.com/2008/11/Understanding-WCF-Services-in-Silverlight-2"&gt;Understanding WCF Services in Silverlight 2&lt;/a&gt;) in which he walks the reader through a thorough tutorial on the proper way of using WCF with Silverlight. If you haven’t already read &lt;a href="http://www.netfxharmonics.com/2008/11/Understanding-WCF-Services-in-Silverlight-2"&gt;Understanding WCF Services in Silverlight 2&lt;/a&gt; I recommend you do so – especially since the remainder of this post will build upon the SecurityOperationBehavior and SecurityOperationInvoker classes David introduces towards the middle of his post. I’d also strongly encourage you to read a prior post by David (&lt;a href="http://www.netfxharmonics.com/2008/11/Architectural-Overview-Creating-Streamlined-Simplified-yet-Scalable-WCF-Connectivity"&gt;Creating Streamlined, Simplified, yet Scalable WCF Connectivity&lt;/a&gt;), which serves as the foundation for his Understanding WCF Services in Silverlight 2 post.&lt;/p&gt;
&lt;p&gt;Go ahead and read those two posts, I’ll wait for you right here.&lt;/p&gt;
&lt;p&gt;Alright, now that you’ve read and understand David’s posts, let’s pick-up where he left off:&lt;/p&gt;
&lt;h3&gt;Using The SecurityOperationBehavior and SecurityOperationInvoker Classes&lt;/h3&gt;
&lt;p&gt;With the knowledge you’ve gained by reading David’s posts you should be able to setup a WCF project with operations secured like so:&lt;/p&gt;
&lt;p&gt;Service Contract:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eeaffc6b-8b3f-4236-891e-1015af8c4233" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.Services.ServiceContracts&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    [&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;]&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ITestService&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    {&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        [&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(AsyncPattern = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;)]&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; BeginFoo(&lt;span style="COLOR: #2b91af"&gt;AsyncCallback&lt;/span&gt; callback, &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; state);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; EndFoo(&lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; result);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Service Implementation (notice the [SecurityOperationBehavior] attribute from David’s post):&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:03af7bb2-c4c5-4517-9d0d-a30f2f9799f3" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Web;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Rjygraham.WcfSecurity.Services;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Rjygraham.WcfSecurity.Services.ServiceContracts;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.ServiceImplementation&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestService&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ITestService&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        [&lt;span style="COLOR: #2b91af"&gt;SecurityOperationBehavior&lt;/span&gt;]&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; BeginFoo(&lt;span style="COLOR: #2b91af"&gt;AsyncCallback&lt;/span&gt; callback, &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; state)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt; result = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(state, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"Bar - {0}"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString()));&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            callback.Invoke(result);&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; EndFoo(&lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; result)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; ((&lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;)result).Data;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Silverlight WCF Client (notice how GetFooAsync method adds the UserName and Password headers):&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c5b7078f-a5b7-4f08-97b8-2e1cb1371c57" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Net;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Ink;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Input;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Shapes;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Rjygraham.WcfSecurity.Services.ServiceContracts;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.Services.Silverlight.Clients&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestServiceClient&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ClientBase&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;ITestService&lt;/span&gt;&amp;gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Constructors&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; TestServiceClient() : &lt;span style="COLOR: #0000ff"&gt;base&lt;/span&gt;() { }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; TestServiceClient(&lt;span style="COLOR: #2b91af"&gt;Binding&lt;/span&gt; binding, &lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt; remoteAddress) : &lt;span style="COLOR: #0000ff"&gt;base&lt;/span&gt;(binding, remoteAddress) { }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; TestServiceClient(&lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt; remoteAddress) : &lt;span style="COLOR: #0000ff"&gt;base&lt;/span&gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;(), remoteAddress) { }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; GetFoo&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; GetFooAsync(&lt;span style="COLOR: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt; callback)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;OperationContextScope&lt;/span&gt; scope = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;OperationContextScope&lt;/span&gt;((&lt;span style="COLOR: #2b91af"&gt;IContextChannel&lt;/span&gt;)Channel))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #2b91af"&gt;MessageHeaders&lt;/span&gt; messageHeadersElement = &lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt;.Current.OutgoingMessageHeaders;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                messageHeadersElement.Add(&lt;span style="COLOR: #2b91af"&gt;MessageHeader&lt;/span&gt;.CreateHeader(&lt;span style="COLOR: #a31515"&gt;"UserName"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"JohnDoe"&lt;/span&gt;));&lt;/li&gt;
    &lt;li&gt;                messageHeadersElement.Add(&lt;span style="COLOR: #2b91af"&gt;MessageHeader&lt;/span&gt;.CreateHeader(&lt;span style="COLOR: #a31515"&gt;"Password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"MyPassword"&lt;/span&gt;));&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;                Channel.BeginFoo(GetFooCallback, callback);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; GetFooCallback(&lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; result)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt; callBack = result.AsyncState &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (callBack != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                callBack.Invoke(Channel.EndFoo(result));&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And then from your application code:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:91a52c6c-94bb-46f7-8e62-4bb51eef7355" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Button_Click(&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #2b91af"&gt;TestServiceClient&lt;/span&gt; client = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestServiceClient&lt;/span&gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"http://localhost:54936/TestService.svc"&lt;/span&gt;));&lt;/li&gt;
    &lt;li&gt;    client.GetFooAsync(Callback);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Callback(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; value)&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #2b91af"&gt;Deployment&lt;/span&gt;.Current.Dispatcher.BeginInvoke(&lt;span style="COLOR: #0000ff"&gt;delegate&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        TestLabel.Text = value;&lt;/li&gt;
    &lt;li&gt;    });&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So far, so good, but as you’ll recall from David’s post, the code that does the actual validation of the username and password is embedded deep within the SecurityOperationInvoker class (this is where we retrieve the UserName and Password headers to do validation):&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:97502429-0a77-4bfe-bb32-9175acda9749" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; Invoke(&lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; instance, &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] inputs, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] outputs)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #008000"&gt;//+ authorization&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #2b91af"&gt;MessageHeaders&lt;/span&gt; messageHeadersElement = &lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt;.Current.IncomingMessageHeaders;&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #2b91af"&gt;Int32&lt;/span&gt; id = messageHeadersElement.FindHeader(&lt;span style="COLOR: #a31515"&gt;"UserName"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;) + messageHeadersElement.FindHeader(&lt;span style="COLOR: #a31515"&gt;"Password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (id &amp;gt; -1)&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; username = messageHeadersElement.GetHeader&amp;lt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #a31515"&gt;"UserName"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt; password = messageHeadersElement.GetHeader&amp;lt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #a31515"&gt;"Password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        SecurityValidator.Authenticate(username, password);&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #008000"&gt;//+&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.Invoke(instance, inputs, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; outputs);&lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #008000"&gt;//+&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FaultException&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(SecurityValidator.Message.InvalidCredentials), SecurityValidator.Message.InvalidCredentials);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;As you can see, this is not an ideal setup.&lt;/p&gt;
&lt;h3&gt;DataAnnotations to the Rescue&lt;/h3&gt;
&lt;p&gt;If you’ve worked with DataAnnotations within Silverlight or RIA Services, you might be familiar with the CustomValidationAttribute which allows you to write custom validation logic for your model classes. You might end up with something like the following:&lt;/p&gt;
&lt;p&gt;The Person class (note the CustomValidationAttribute declared on the Person class):&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e23dbd7-de4b-4ddd-9070-ef8bfebdd63b" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel.DataAnnotations;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Net;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Ink;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Input;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Shapes;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.SilverlightClient&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    [&lt;span style="COLOR: #2b91af"&gt;CustomValidation&lt;/span&gt;(&lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;PersonValidator&lt;/span&gt;), &lt;span style="COLOR: #a31515"&gt;"ValidateAgeGender"&lt;/span&gt;)]&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Person&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    {&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        [&lt;span style="COLOR: #2b91af"&gt;Required&lt;/span&gt;]&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; FirstName { &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        [&lt;span style="COLOR: #2b91af"&gt;Required&lt;/span&gt;]&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; LastName { &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        [&lt;span style="COLOR: #2b91af"&gt;Range&lt;/span&gt;(0d, 100d)]&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; Age { &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; IsMale { &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The PersonValidator class:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f29ecca7-6d93-44ca-8873-be6d2b3b840a" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel.DataAnnotations;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Net;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Ink;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Input;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Windows.Shapes;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.SilverlightClient&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;{&lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PersonValidator&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    {&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ValidationResult&lt;/span&gt; ValidateAgeGender(&lt;span style="COLOR: #2b91af"&gt;Person&lt;/span&gt; value)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (value.IsMale &amp;amp;&amp;amp; value.Age &amp;lt; 18)&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ValidationResult&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"All males must be 18 years of age or older."&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!value.IsMale &amp;amp;&amp;amp; value.Age &amp;lt; 21)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ValidationResult&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"All females must be 21 years of age or older."&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ValidationResult&lt;/span&gt;.Success;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    }&lt;/li&gt;
    &lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Obviously this is a contrived example, but it illustrates the usefulness and the great extensibility the CustomValidationAttribute class provides DataAnnotations. The initial rendition of the SecurityOperationInvoker is practically begging for the same type of extensibility. In order to do so, we’ll need to modify the SecurityOperationBehavior class to accept a type and method name to pass to the SecurityOperationInvoker class. After some quick &lt;a target="_blank" href="http://www.red-gate.com/products/reflector/"&gt;Reflectoring&lt;/a&gt; of the CustomValidationAttribute class we end up with a SecurityOperationBehavior that looks like this:&lt;/p&gt;
&lt;p&gt;Modified SecurityOperationBehavior class:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:82b120da-2900-49b9-bf70-c4313f09d9d9" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 3em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Globalization;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Reflection;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Description;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Dispatcher;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.Services&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    [&lt;span style="COLOR: #2b91af"&gt;AttributeUsage&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;AttributeTargets&lt;/span&gt;.Method)]&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityOperationBehavior&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Attribute&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;IOperationBehavior&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Fields&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; _cachedErrorMessage;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; _verifiedWellFormed;&lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; _method;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; _validatorType;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Constructors&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; SecurityOperationBehavior(&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; validatorType, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; method)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            _validatorType = validatorType;&lt;/li&gt;
    &lt;li&gt;            _method = method;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; errorMessage = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!IsAttributeWellFormed(&lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; errorMessage))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(errorMessage);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; IOperationBehavior Members&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; AddBindingParameters(&lt;span style="COLOR: #2b91af"&gt;OperationDescription&lt;/span&gt; operationDescription, System.ServiceModel.Channels.&lt;span style="COLOR: #2b91af"&gt;BindingParameterCollection&lt;/span&gt; bindingParameters)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #008000"&gt;// Intentionally left empty. &lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; ApplyClientBehavior(&lt;span style="COLOR: #2b91af"&gt;OperationDescription&lt;/span&gt; operationDescription, &lt;span style="COLOR: #2b91af"&gt;ClientOperation&lt;/span&gt; clientOperation)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #008000"&gt;// Intentionally left empty. &lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; ApplyDispatchBehavior(&lt;span style="COLOR: #2b91af"&gt;OperationDescription&lt;/span&gt; operationDescription, &lt;span style="COLOR: #2b91af"&gt;DispatchOperation&lt;/span&gt; dispatchOperation)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            dispatchOperation.Invoker = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityOperationInvoker&lt;/span&gt;(dispatchOperation.Invoker, &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._validatorType, &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._method);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Validate(&lt;span style="COLOR: #2b91af"&gt;OperationDescription&lt;/span&gt; operationDescription)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #008000"&gt;// Intentionally left empty. &lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Validation Methods&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; IsAttributeWellFormed(&lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; errorMessage)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!_verifiedWellFormed)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                _verifiedWellFormed = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                _cachedErrorMessage = ValidateTypeParameter();&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (_cachedErrorMessage == &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                {&lt;/li&gt;
    &lt;li&gt;                    _cachedErrorMessage = ValidateMethodParameter();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                }&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            errorMessage = _cachedErrorMessage;&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; (errorMessage == &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; ValidateTypeParameter()&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._validatorType == &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;@"The SecurityOperationBehavior.ValidatorType was not specified."&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!_validatorType.IsVisible)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture, &lt;span style="COLOR: #a31515"&gt;@"The custom validation type '{0}' must be public."&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { _validatorType.Name });&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; ValidateMethodParameter()&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;._method))&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;"The SecurityOperationBehavior.Method was not specified."&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #2b91af"&gt;MethodInfo&lt;/span&gt; method = _validatorType.GetMethod(_method, &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Public | &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Static);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (method == &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture, &lt;span style="COLOR: #a31515"&gt;@"The SecurityOperationBehavior method '{0}' does not exist in type '{1}' or is not public and static."&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { _method, _validatorType.Name });&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (method.ReturnType != &lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture, &lt;span style="COLOR: #a31515"&gt;@"The SecurityOperationBehavior method '{0}' in type '{1}' must return System.Boolean. Use true to represent success."&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { _method, _validatorType.Name });&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #2b91af"&gt;ParameterInfo&lt;/span&gt;[] parameters = method.GetParameters();&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; ((parameters.Length != 1))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture, &lt;span style="COLOR: #a31515"&gt;@"The SecurityOperationBehavior method '{0}' in type '{1}' must match the expected signature: public static bool {0}(System.ServiceModel.OperationContext context)."&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { _method, _validatorType.Name });&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (parameters[0].ParameterType != &lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt;))&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture, &lt;span style="COLOR: #a31515"&gt;@"The SecurityOperationBehavior method '{0}' in type '{1}' must match the expected signature: public static bool {0}(System.ServiceModel.OperationContext context)."&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { _method, _validatorType.Name });&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;        &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    }&lt;/li&gt;
    &lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And we’ll need to modify the SecurityOperationInvoker like so:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:abe86a40-6e64-48cd-b50a-bf4c8dc12dc0" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Reflection;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Dispatcher;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.Services&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityOperationInvoker&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IOperationInvoker&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    {&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Fields&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MethodInfo&lt;/span&gt; _methodInfo;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Properties&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IOperationInvoker&lt;/span&gt; InnerOperationInvoker { &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Boolean&lt;/span&gt; IsSynchronous&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt; { &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.IsSynchronous; }&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Constructors&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; SecurityOperationInvoker(&lt;span style="COLOR: #2b91af"&gt;IOperationInvoker&lt;/span&gt; operationInvoker, &lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; validatorType, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; method)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;.InnerOperationInvoker = operationInvoker;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            _methodInfo = validatorType.GetMethod(method, &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Public | &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Static);&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Public Methods&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] AllocateInputs()&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.AllocateInputs();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; Invoke(&lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; instance, &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] inputs, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] outputs)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (Validate(&lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt;.Current))&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.Invoke(instance, inputs, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; outputs);&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FaultException&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Unauthorized."&lt;/span&gt;), &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FaultReason&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Unauthorized."&lt;/span&gt;));&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; InvokeBegin(&lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; instance, &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] inputs, &lt;span style="COLOR: #2b91af"&gt;AsyncCallback&lt;/span&gt; callback, &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; state)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (Validate(&lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt;.Current))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.InvokeBegin(instance, inputs, callback, state);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FaultException&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Unauthorized."&lt;/span&gt;), &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FaultReason&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Unauthorized."&lt;/span&gt;));&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; InvokeEnd(&lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt; instance, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Object&lt;/span&gt;[] outputs, &lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; result)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; InnerOperationInvoker.InvokeEnd(instance, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; outputs, result);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;#region&lt;/span&gt; Private Methods&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; Validate(&lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt; context)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; result = &lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;try&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #2b91af"&gt;MethodInfo&lt;/span&gt; info = _methodInfo;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                result = (&lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt;)info.Invoke(&lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;[] { context });&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;TargetInvocationException&lt;/span&gt; exception)&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (exception.InnerException != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;
    &lt;li&gt;                {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                    &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt; exception.InnerException;&lt;/li&gt;
    &lt;li&gt;                }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;throw&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        &lt;span style="COLOR: #0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The changes to the SecurityOperationBehavior class are very straight forward, with most changes consisting of validating the validator class and method name. The interesting changes lie in the SecurityOperationInvoker class. In the Invoker class, we grab the MethodInfo of the validator class which we use in the Validate (lines 74-91 in the code snippet above) method called from within the Invoke (lines 46-53) and InvokeBegin (lines 55-62) methods of the Invoker class. You’ll see that the Validate method simply invokes the specified method on the validator class and returns the result. If Validate returns true, we continue to invoke the web service, otherwise we throw a &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/dd470096(VS.95).aspx"&gt;FaultException&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With our modified SecurityOperationBehavior and SecurityOperationInvoker classes we can now create our validator class:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:de665b86-7d17-4dca-a58d-f640151d2981" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Web;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.ServiceImplementation&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestServiceValidator&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; ValidateUserNameAndPassword(&lt;span style="COLOR: #2b91af"&gt;OperationContext&lt;/span&gt; context)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #2b91af"&gt;MessageHeaders&lt;/span&gt; headers = context.IncomingMessageHeaders;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (headers.FindHeader(&lt;span style="COLOR: #a31515"&gt;"UserName"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;) &amp;gt; -1 &amp;amp;&amp;amp; headers.FindHeader(&lt;span style="COLOR: #a31515"&gt;"Password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;) &amp;gt; -1)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; userName = headers.GetHeader&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #a31515"&gt;"UserName"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; password = headers.GetHeader&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #a31515"&gt;"Password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (userName == &lt;span style="COLOR: #a31515"&gt;"JohnDoe"&lt;/span&gt; &amp;amp;&amp;amp; password == &lt;span style="COLOR: #a31515"&gt;"MyPassword"&lt;/span&gt;)&lt;/li&gt;
    &lt;li&gt;                {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;                }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    }&lt;/li&gt;
    &lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And modify our service implementation:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:45d8bbf6-5523-47da-aff5-b28277a5cc8d" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; System.Web;&lt;/li&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Rjygraham.WcfSecurity.Services;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Rjygraham.WcfSecurity.Services.ServiceContracts;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="COLOR: #0000ff"&gt;namespace&lt;/span&gt; Rjygraham.WcfSecurity.ServiceImplementation&lt;/li&gt;
    &lt;li&gt;{&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestService&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ITestService&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;    {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;        [&lt;span style="COLOR: #2b91af"&gt;SecurityOperationBehavior&lt;/span&gt;(&lt;span style="COLOR: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;TestServiceValidator&lt;/span&gt;), &lt;span style="COLOR: #a31515"&gt;"ValidateUserNameAndPassword"&lt;/span&gt;)]&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; BeginFoo(&lt;span style="COLOR: #2b91af"&gt;AsyncCallback&lt;/span&gt; callback, &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; state)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt; result = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(state, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"Bar - {0}"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString()));&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            callback.Invoke(result);&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; EndFoo(&lt;span style="COLOR: #2b91af"&gt;IAsyncResult&lt;/span&gt; result)&lt;/li&gt;
    &lt;li&gt;        {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; ((&lt;span style="COLOR: #2b91af"&gt;CompletedAsyncResult&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;)result).Data;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;    }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;By pulling the validation code out of the SecurityOperationInvoker class we’ve made it 100% extensible – just like the CustomValidationAttribute of DataAnnotations. Since every application may use different validation logic having a solution that is extensible is important. Note that we are using Reflection here so there might be some minor performance hits – especially when the service is firing up for the first time. However, since we’re caching the MethodInfo inside the Invoker class, the only performance hit we’ll take when the WCF method is called is the Invoke within the Validate method of the SecurityOperationInvoker.&lt;/p&gt;
&lt;p&gt;I hope you find this solution as useful as I did. Feel free to grab the code below and make whatever changes you need.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rjygraham.com/attachments/rjygraham.wcfsecurity.zip"&gt;Rjygraham.WcfSecurity.zip&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/13.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/10/22/reusable-maintainable-and-extensible-wcf-security.aspx</guid>
            <pubDate>Fri, 23 Oct 2009 02:34:48 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/13.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/10/22/reusable-maintainable-and-extensible-wcf-security.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/13.aspx</wfw:commentRss>
        </item>
        <item>
            <title>HTC Imagio Hands-on</title>
            <link>http://www.rjygraham.com/archive/2009/10/19/12.aspx</link>
            <description>&lt;p&gt;Today I posted a review of the HTC Imagio over on &lt;a href="http://techburgh.com" target="_blank"&gt;Techburgh.com&lt;/a&gt;. You can read the review here: &lt;a title="http://techburgh.com/blog/2009/10/19/review-verizon-htc-imagio-hands-on/" href="http://techburgh.com/blog/2009/10/19/review-verizon-htc-imagio-hands-on/" target="_blank"&gt;http://techburgh.com/blog/2009/10/19/review-verizon-htc-imagio-hands-on/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/12.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/10/19/12.aspx</guid>
            <pubDate>Mon, 19 Oct 2009 21:46:57 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/12.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/10/19/12.aspx#feedback</comments>
            <slash:comments>12</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/12.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Modifying the DataAnnotationsModelBinder to enable seamless validation in ASP.NET MVC</title>
            <category>MVC</category>
            <category>Validation</category>
            <link>http://www.rjygraham.com/archive/2009/10/10/modifying-the-dataannotationsmodelbinder-to-enable-seamless-validation-in-aspnet-mvc.aspx</link>
            <description>&lt;p&gt;ASP.NET MVC 2 promises to bring us a seamless client-side/server-side experience much like we currently have in WebForms. However, for those of us developing web apps in MVC 1 we’ve had to resort to rolling our own solution or using a patchwork of validation components. In this post I’ll briefly discuss modifications I made to the &lt;a target="_blank" href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471"&gt;DataAnnotationsModelBinder&lt;/a&gt; so it would work with DataAnnotations, xVal, and jQuery.Validate.&lt;/p&gt;
&lt;h2&gt;xVal&lt;/h2&gt;
&lt;p&gt;If you’re not already familiar with xVal, I’d suggest checking out its &lt;a target="_blank" href="http://xval.codeplex.com/"&gt;Codeplex site&lt;/a&gt; and and reading &lt;a target="_blank" href="http://blog.codeville.net/2009/01/10/xval-a-validation-framework-for-aspnet-mvc/"&gt;this blog post&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;DataAnnotations&lt;/h2&gt;
&lt;p&gt;The DataAnnotations namespace was introduced in .NET 3.5 SP1 and provides developers the means to declaratively add validation rules to their model classes. For a more in depth look at DataAnnotations and how we’ll be using it here, check out &lt;a target="_blank" href="http://bradwilson.typepad.com/blog/2009/04/dataannotations-and-aspnet-mvc.html"&gt;this excellent post&lt;/a&gt; by Brad Wilson.&lt;/p&gt;
&lt;h2&gt;DataAnnotationsModelBinder&lt;/h2&gt;
&lt;p&gt;In Brad Wilson’s post I linked to above, he mentioned how they had extended the default ASP.NET MVC model binder in the form of the &lt;a target="_blank" href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471"&gt;DataAnnotationsModelBinder&lt;/a&gt;. Once you’ve downloaded the DataAnnotationsModelBinder and read Brad Wilson’s blog post, take a look at the answer by Martijn Laarman to &lt;a target="_blank" href="http://stackoverflow.com/questions/820468/how-does-dataannotationsmodelbinder-work-with-custom-viewmodels"&gt;this question&lt;/a&gt; on StackOverflow. I think you’ll agree with the modifications he made to the base DataAnnotationsModelBinder.&lt;/p&gt;
&lt;h2&gt;jQuery.Validate&lt;/h2&gt;
&lt;p&gt;jQuery.Validate is in my opinion the best validation plug-in for jQuery and it’s gained wide support from the development community (including Microsoft). The easiest way to include jQuery and jQuery.Validate in your MVC app is to use the &lt;a target="_blank" href="http://www.asp.net/ajax/CDN/"&gt;Microsoft Ajax CDN&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Modifying the DataAnnotationsModelBinder&lt;/h2&gt;
&lt;p&gt;Alright, we’ve now covered all the pieces for our patchwork validation solution but there’s one last thing we need to take care of. If you were paying close attention while reading Brad Wilson’s post, you’ll have noticed he mentioned they used a preview version of the .NET 4.0 System.ComponentModel.DataAnnotations assembly while creating the DataAnnotationsModelBinder. Unfortunately, xVal was compiled against the System.ComponentModel.DataAnnotations assembly that ships with .NET 3.5 SP1 and is therefore incompatible with the DataAnnotationsModelBinder out-of-the-box.&lt;/p&gt;
&lt;p&gt;To get the DataAnnotationsModelBinder in shape to work with our solution we need to do the following:&lt;/p&gt;
&lt;p&gt;1. Open up the DataAnnotationsModelBinder project &lt;/p&gt;
&lt;p&gt;2. Replace the reference to the .NET 4.0 preview System.ComponentModel.DataAnnotations assembly with the .NET 3.5 SP1 version. &lt;/p&gt;
&lt;p&gt;3. Modify the OnModelUpdated method from: &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:868874e8-5006-47c8-9e46-95c70aa20e19" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; OnModelUpdated(&lt;span style="COLOR: #2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext,&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                                               &lt;span style="COLOR: #2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext) {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #008000"&gt;// Base version calls IDataErrorInfo&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;base&lt;/span&gt;.OnModelUpdated(controllerContext, bindingContext);&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #008000"&gt;// If the model is invalid, don't run model-level validation rules&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!ModelIsValid(bindingContext)) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; typeDescriptor = GetTypeDescriptor(bindingContext.Model, bindingContext.ModelType);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; validationContext = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; ValidationContext(bindingContext.Model, &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt;            validationContext.DisplayName = GetDisplayName(typeDescriptor);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            ValidationResult validationResult;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt; attribute &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; typeDescriptor.GetAttributes&amp;lt;&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt;&amp;gt;()) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!attribute.TryValidate(bindingContext.Model, validationContext, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; validationResult)) {&lt;/li&gt;
    &lt;li&gt;                    bindingContext.ModelState.AddModelError(bindingContext.ModelName, validationResult.ErrorMessage);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                }&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
to:
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6e2a23bb-aa56-4d9a-92d9-806bf3d574ef" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; OnModelUpdated(&lt;span style="COLOR: #2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext, &lt;span style="COLOR: #2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #008000"&gt;// Base version calls IDataErrorInfo&lt;/span&gt;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;base&lt;/span&gt;.OnModelUpdated(controllerContext, bindingContext);&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #008000"&gt;// If the model is invalid, don't run model-level validation rules&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!ModelIsValid(bindingContext)) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; typeDescriptor = GetTypeDescriptor(bindingContext.Model, bindingContext.ModelType);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt; attribute &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; typeDescriptor.GetAttributes&amp;lt;&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt;&amp;gt;())&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!attribute.IsValid(bindingContext.Model))&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                {&lt;/li&gt;
    &lt;li&gt;                    bindingContext.ModelState.AddModelError(bindingContext.ModelName, attribute.ErrorMessage);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                }&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;4. Modify the OnPropertyValidating method from:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8a0f3016-7e29-4ccf-aa10-3049821ec461" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; OnPropertyValidating(&lt;span style="COLOR: #2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext,&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                                                     &lt;span style="COLOR: #2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext,&lt;/li&gt;
    &lt;li&gt;                                                     &lt;span style="COLOR: #2b91af"&gt;PropertyDescriptor&lt;/span&gt; propertyDescriptor,&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                                                     &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; value) {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; modelStateKey = CreateSubPropertyName(bindingContext.ModelName, propertyDescriptor.Name);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; validationContext = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; ValidationContext(bindingContext.Model, &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;, &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
    &lt;li&gt;            validationContext.DisplayName = GetDisplayName(propertyDescriptor);&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; result = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            ValidationResult validationResult;&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt; attribute &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; GetValidationAttributes(propertyDescriptor)) {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!attribute.TryValidate(value, validationContext, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; validationResult)) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                    bindingContext.ModelState.AddModelError(modelStateKey, validationResult.ErrorMessage);&lt;/li&gt;
    &lt;li&gt;                    result = &lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                }&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;to:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:868b1859-1114-4157-b782-2752013f9bc1" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;override&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; OnPropertyValidating(&lt;span style="COLOR: #2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext, &lt;span style="COLOR: #2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext, &lt;span style="COLOR: #2b91af"&gt;PropertyDescriptor&lt;/span&gt; propertyDescriptor, &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; value)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; modelStateKey = CreateSubPropertyName(bindingContext.ModelName, propertyDescriptor.Name);&lt;/li&gt;
    &lt;li&gt;           &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;bool&lt;/span&gt; result = &lt;span style="COLOR: #0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;
    &lt;li&gt;           &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ValidationAttribute&lt;/span&gt; attribute &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; GetValidationAttributes(propertyDescriptor))&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (!attribute.IsValid(value))&lt;/li&gt;
    &lt;li&gt;                {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                    bindingContext.ModelState.AddModelError(modelStateKey, attribute.ErrorMessage);&lt;/li&gt;
    &lt;li&gt;                }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;5. Modify the GetDisplayName method from:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c00bdb39-2d8a-48d1-a7d3-8b8e3bea08b0" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;internal&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; GetDisplayName(&lt;span style="COLOR: #2b91af"&gt;PropertyDescriptor&lt;/span&gt; descriptor) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; displayAttribute = descriptor.GetAttribute&amp;lt;DisplayAttribute&amp;gt;();&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (displayAttribute != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(displayAttribute.Name)) {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; displayAttribute.Name;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; displayNameAttribute = descriptor.GetAttribute&amp;lt;&lt;span style="COLOR: #2b91af"&gt;DisplayNameAttribute&lt;/span&gt;&amp;gt;();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (displayNameAttribute != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(displayNameAttribute.DisplayName)) {&lt;/li&gt;
    &lt;li&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; displayNameAttribute.DisplayName;&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            }&lt;/li&gt;
    &lt;li&gt; &lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; descriptor.Name;&lt;/li&gt;
    &lt;li&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;to:&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:35a0053b-0996-4920-ba1b-f4a103827109" class="wlWriterEditableSmartContent"&gt;
&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="BACKGROUND: #ddd; MAX-HEIGHT: 300px; OVERFLOW: auto"&gt;
&lt;ol style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2.5em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
    &lt;li&gt;&lt;span style="COLOR: #0000ff"&gt;internal&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; GetDisplayName(&lt;span style="COLOR: #2b91af"&gt;ICustomTypeDescriptor&lt;/span&gt; descriptor)&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        {&lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;var&lt;/span&gt; displayNameAttribute = descriptor.GetAttribute&amp;lt;&lt;span style="COLOR: #2b91af"&gt;DisplayNameAttribute&lt;/span&gt;&amp;gt;();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;            &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (displayNameAttribute != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(displayNameAttribute.DisplayName))&lt;/li&gt;
    &lt;li&gt;            {&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;                &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; displayNameAttribute.DisplayName;&lt;/li&gt;
    &lt;li&gt;            }&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt; &lt;/li&gt;
    &lt;li&gt;            &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; descriptor.GetClassName().Split(&lt;span style="COLOR: #a31515"&gt;'.'&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;'+'&lt;/span&gt;).Last();&lt;/li&gt;
    &lt;li style="BACKGROUND: #f3f3f3"&gt;        }&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;6. Rebuild the DataAnnotationsModelBinder project and reference that assembly in your MVC project.&lt;/p&gt;
&lt;p&gt;Basically all we did in making these modifications is remove the .NET 4.0 specific dependencies which will make the DataAnnotationsModelBinder compatible with xVal.&lt;/p&gt;
&lt;p&gt;Check out the sample project which shows how to glue all these pieces together and also includes a modified version of the DataAnnotationsModelBinder class.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rjygraham.com/attachments/mvcsandbox.zip"&gt;MvcSandbox.zip&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/11.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/10/10/modifying-the-dataannotationsmodelbinder-to-enable-seamless-validation-in-aspnet-mvc.aspx</guid>
            <pubDate>Sat, 10 Oct 2009 19:26:21 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/11.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/10/10/modifying-the-dataannotationsmodelbinder-to-enable-seamless-validation-in-aspnet-mvc.aspx#feedback</comments>
            <slash:comments>25</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/11.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using the MVC XML Sitemap in your ASP.NET MVC project.</title>
            <category>MVC</category>
            <link>http://www.rjygraham.com/archive/2009/08/01/using-the-mvc-xml-sitemap-in-your-aspnet-mvc-project.aspx</link>
            <description>&lt;p&gt;This post is a simple walkthrough to illustrate the usage the MVC XML Sitemap project.&lt;/p&gt;
&lt;p&gt;If you haven’t already, grab the source here: &lt;a title="http://mvcxmlsitemap.codeplex.com/Release/ProjectReleases.aspx" href="http://mvcxmlsitemap.codeplex.com/Release/ProjectReleases.aspx"&gt;http://mvcxmlsitemap.codeplex.com/Release/ProjectReleases.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Once you’ve downloaded it, go ahead and unzip it, open the solution up in Visual Studio and do a rebuild so the assembly is compiled.&lt;/p&gt;
&lt;h4&gt;A Simple Sitemap Example&lt;/h4&gt;
&lt;ol&gt;
    &lt;li&gt;Create a new ASP.NET MVC web application (the name is not important) and add a reference to the Cintellect.Web.Mvc.Sitemap assembly to ASP.NET MVC web application you just compiled. &lt;br /&gt;
     &lt;a rel="lightbox" href="http://rjygraham.com/Images/UsingtheMVCXMLSitemapinyourASP.NETMVCpr_C67/image.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" width="194" height="244" src="http://rjygraham.com/Images/UsingtheMVCXMLSitemapinyourASP.NETMVCpr_C67/image_thumb.png" /&gt;&lt;/a&gt; &lt;/li&gt;
    &lt;li&gt;Now open up the HomeController in the Controllers folder and add the following using statement to the class: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; Cintellect.Web.Mvc.Sitemap;&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;You’re now able to “opt in” actions in the HomeController by placing a [Sitemap] attribute on the action, like so: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;[Sitemap]&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; ActionResult Index()&lt;br /&gt;{&lt;br /&gt;    ViewData[&lt;span style="COLOR: #006080"&gt;"Message"&lt;/span&gt;] = &lt;span style="COLOR: #006080"&gt;"Welcome to ASP.NET MVC!"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; View();&lt;br /&gt;}&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now create a Sitemap action on the HomeController: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; ContentResult SiteMap()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; Content(SitemapFactory.Create(), &lt;span style="COLOR: #006080"&gt;"text/xml"&lt;/span&gt;, System.Text.Encoding.UTF8);&lt;br /&gt;}&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Press F5 to start debugging, then navigate to the Sitemap action and you should see something similar to the following:
    &lt;div id="codeSnippetWrapper"&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;xml&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;version&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="1.0"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://www.sitemaps.org/schemas/sitemap/0.9"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/Index&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;[Sitemap] Attribute Named Parameters&lt;/h4&gt;
&lt;p&gt;When you added the [Sitemap] attribute to the Index action, you might have noticed there are a number named parameters for which you can specify values. Three of these parameters correspond to the XML tags specified in the &lt;a target="_blank" href="http://www.sitemaps.org/protocol.php"&gt;sitemaps.org protocol&lt;/a&gt;, while the others are extended functionality of the Mvc Xml Sitemap framework.&lt;/p&gt;
&lt;p&gt;Before we take a look at some more advanced examples, let’s review what each of the named parameters does.&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;ChangeFrequency – Allows you to explicitly indicate the change frequency of the action. Valid values are: always, hourly, daily, weekly, monthly, yearly, never. Please see the &lt;a target="_blank" href="http://www.sitemaps.org/protocol.php"&gt;sitemaps.org protocol&lt;/a&gt;for more information. &lt;/li&gt;
    &lt;li&gt;LastModified – Ignore this parameter for right now, you can’t specify the value for it in the [Sitemap] attribute. &lt;/li&gt;
    &lt;li&gt;Priority – Allows you to explicitly indicate the priority of this action relative to others on your site. Valid values range from 0.0 to 1.0. &lt;/li&gt;
    &lt;li&gt;IgnoreAuthorizeAttribute – This parameter must be set to true on all actions that have an [Authorize] attribute, and serves merely as verification that you want a protected page URL to be exposed in your sitemap. &lt;/li&gt;
    &lt;li&gt;QueryKey – The sitemap framework allows you to pass the SitemapFactory class delegate functions to create URLs that go deeper than just the controller action. For instance, let’s say you have a Product controller with a Details action that accepts a product id as a parameter in the route (i.e. &lt;a href="http://www.yourdomain.com/Products/Details/1"&gt;http://www.yourdomain.com/Products/Details/1&lt;/a&gt;), you can pass a function to the SitemapFactory which will retrieve all products for inclusion in the sitemap. This parameter is simply specifies which delegate function should be called for the current action. &lt;/li&gt;
    &lt;li&gt;Route – The sitemap framework will work out of the box with the default {controller}/{action}/{id} route of ASP.NET MVC. However, there are times when you’ll want to specify more advanced routes. This parameter allows you to specify the route which the current action will be executed under so that the URL is generated correctly. &lt;/li&gt;
    &lt;li&gt;SitemapProfile – The sitemap framework allows you to create sitemap profiles in the web.config in which you can provide values for any of the previously discussed named parameters. This parameter tells the framework which profile to load for the action. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think specifying values for ChangeFrequency and Priority are fairly straight forward, so let’s jump into two more advanced topics:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Creating sitemap profiles in the web.config &lt;/li&gt;
    &lt;li&gt;Using QueryKey to specify a delegate to return URLs that are deeper than just the controller action. &lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Creating Sitemap Profiles in the Web.config&lt;/h4&gt;
&lt;p&gt;Since many of your actions may share the same sitemap configuration, storing these configurations as a profile in the web.config is a great way to reduce redundant code and provide a way for bulk update. It’s also great because if you need to change a value, you won’t need to recompile your code and redeploy.&lt;/p&gt;
&lt;p&gt;To enable sitemap profiles in your web.config, follow these steps:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Modify the &amp;lt;configSections&amp;gt; element to the following (note the inclusion of the new cintellect.web.mvc.sitemap section): &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;configSections&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="cintellect.web.mvc.sitemap"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Cintellect.Web.Mvc.Sitemap.SitemapSection, Cintellect.Web.Mvc.Sitemap"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="system.web.extensions"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="scripting"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="scriptResourceHandler"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;requirePermission&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;allowDefinition&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MachineToApplication"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="webServices"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="jsonSerialization"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;requirePermission&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;allowDefinition&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Everywhere"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="profileService"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;requirePermission&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;allowDefinition&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MachineToApplication"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="authenticationService"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;requirePermission&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;allowDefinition&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MachineToApplication"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;section&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="roleService"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;type&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;requirePermission&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="false"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;allowDefinition&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="MachineToApplication"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sectionGroup&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;configSections&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Add the following section between the &amp;lt;connectionStrings&amp;gt; and &amp;lt;system.web&amp;gt; sections: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;cintellect.web.mvc.sitemap&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sitemapProfiles&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;clear&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;add&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;name&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="HomeWeeklyProfile"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;route&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Default"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;changeFrequency&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="weekly"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;priority&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="0.7"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;sitemapProfiles&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;cintellect.web.mvc.sitemap&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now, modify the About action of the HomeController to: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;[Sitemap(SitemapProfile = &lt;span style="COLOR: #006080"&gt;"HomeWeeklyProfile"&lt;/span&gt;)]&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; ActionResult About()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; View();&lt;br /&gt;}&lt;/pre&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Press F5 to start debugging, then navigate to the Sitemap action and you should see something similar to the following: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;xml&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;version&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="1.0"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://www.sitemaps.org/schemas/sitemap/0.9"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/Index&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;changefreq&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;weekly&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;changefreq&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;priority&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;0.7&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;priority&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/About&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Notice how the sitemap framework picked up the change frequency and priority which was specified in the profile. Pretty neat, eh?&lt;/p&gt;
&lt;h4&gt;Using QueryKey to Specify a Delegate to Return URLs &lt;/h4&gt;
&lt;p&gt;What I’m about to show you next is probably my favorite feature of the framework so far – mainly because it opens up the framework to the developer.&lt;/p&gt;
&lt;p&gt;All the work we’ll be doing this time is in the HomeController.&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Add a new action called Detail and add a [Sitemap] attribute with the QueryKey = “GetAllProducts”, like this: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;[Sitemap(QueryKey = &lt;span style="COLOR: #006080"&gt;"GetAllProducts"&lt;/span&gt;)]&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; ActionResult Detail()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; View();&lt;br /&gt;}&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;Add a new static method to the HomeController called GetAllProducts: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;private&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; Url[] GetAllProducts()&lt;br /&gt;{&lt;br /&gt;    List&amp;lt;Url&amp;gt; result = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Url&amp;gt;();&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; baseUrl = &lt;span style="COLOR: #006080"&gt;@"http://localhost:58496/Home/Detail"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 1) });&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 2) });&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 3) });&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 4) });&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 5) });&lt;br /&gt;    result.Add(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Url() { Location = String.Format(&lt;span style="COLOR: #006080"&gt;"{0}/{1}"&lt;/span&gt;, baseUrl, 6) });&lt;br /&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; result.ToArray();&lt;br /&gt;}&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;Update the Sitemap action to the following: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; ContentResult SiteMap()&lt;br /&gt;{&lt;br /&gt;    Dictionary&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;, Func&amp;lt;Url[]&amp;gt;&amp;gt; queries = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;, Func&amp;lt;Url[]&amp;gt;&amp;gt;();&lt;br /&gt;    queries.Add(&lt;span style="COLOR: #006080"&gt;"GetAllProducts"&lt;/span&gt;, GetAllProducts);&lt;br /&gt;&lt;br /&gt;    &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; Content(SitemapFactory.Create(queries), &lt;span style="COLOR: #006080"&gt;"text/xml"&lt;/span&gt;, System.Text.Encoding.UTF8);&lt;br /&gt;}&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;Press F5 to start debugging, then navigate to the Sitemap action and you should see something similar to the following: &lt;br /&gt;
    &lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: &amp;quot;Courier New&amp;quot;, courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;xml&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;version&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="1.0"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="http://www.sitemaps.org/schemas/sitemap/0.9"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/Index&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;changefreq&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;weekly&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;changefreq&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;priority&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;0.7&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;priority&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/About&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/home/Detail&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/1&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/2&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/3&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/4&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/5&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://localhost:58496/Home/Detail/6&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;loc&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;url&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;urlset&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s briefly walk through this. We created a new action and decorated it with a [Sitemap] attribute. The sitemap attribute is looking for a query with a key of “GetAllProducts” to be passed to the Create method of the SitemapFactory.&lt;/p&gt;
&lt;p&gt;We then added the GetAllProducts static method to the HomeController. This function had a return type of Url[] since that is the only return type currently accepted by SitemapFactory for any delegates passed to it. The GetAllProducts method contained some business logic to create an array of Url. In this case we were simply creating instances of the Url class and adding it to the List, however, this method could contain some complicated logic which retrieves the Urls via LINQ to SQL, Entity Framework, WCF, or practically any other means.&lt;/p&gt;
&lt;p&gt;Finally we updated our Sitemap action to be aware of the queries we were sending to it. Notice how we instantiated the queries dictionary with Func&amp;lt;Url[]&amp;gt; as the value of the dictionary, which is exactly what the SitemapFactory is expecting - a function with a return type of Url[].&lt;/p&gt;
&lt;h4&gt;Wrap Up&lt;/h4&gt;
&lt;p&gt;Hopefully this is a useful walkthrough of how to use the Mvc Xml Sitemap framework. Please feel free to leave comments either here or on Codeplex.&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/9.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/08/01/using-the-mvc-xml-sitemap-in-your-aspnet-mvc-project.aspx</guid>
            <pubDate>Sat, 01 Aug 2009 18:07:17 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/9.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/08/01/using-the-mvc-xml-sitemap-in-your-aspnet-mvc-project.aspx#feedback</comments>
            <slash:comments>59</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/9.aspx</wfw:commentRss>
        </item>
        <item>
            <title>I&amp;rsquo;m back from being MIA</title>
            <link>http://www.rjygraham.com/archive/2009/08/01/8.aspx</link>
            <description>&lt;p&gt;So I’m back from being MIA for oh… about 4 months. :-)&lt;/p&gt;  &lt;p&gt;I had a lot going on in my personal life and just couldn’t find the time or motivation to write any posts (there I go making excuses again). Part of the reason I’ve not had time to write is that I’ve been spending a lot of time working with Silverlight, specifically SL3 and I’m loving it. Silverlight is such a powerful development platform and the tooling support is great – minus the designer surface no longer working in VS2008 for SL3. The only good thing that’s come from that is I’ve been forced to use Blend 3 + SketchFlow and I’ve fallen in love with it. I introduced SketchFlow at work for doing rapid prototyping and everyone loves it – designers, developers, and stakeholders. If any of you Microsofties out there read this, I wouldn’t mind if a copy of Expression Studio 3 mysteriously showed up on my doorstep. ;-)&lt;/p&gt;  &lt;p&gt;Anyway, much has happened since I posted last:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Silverlight 3 RTM &lt;/li&gt;    &lt;li&gt;Expression Blend + SketchFlow RTM &lt;/li&gt;    &lt;li&gt;Azure July 2009 CTP &lt;/li&gt;    &lt;li&gt;RIA Services July 2009 CTP &lt;/li&gt;    &lt;li&gt;ASP.NET MVC 2 Preview 1 &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;That just means we have a lot of new goodies to play with and there are now plenty of topics for me to write about. :-) I’ll be kicking off my next round of posts with one about the ASP.NET MVC XML Sitemap project I just launched on Codeplex. If I can keep my eyes open long enough I might just hammer it out tonight.&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/8.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/08/01/8.aspx</guid>
            <pubDate>Sat, 01 Aug 2009 04:32:33 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/8.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/08/01/8.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/8.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Simple Silverlight Security Preview</title>
            <category>Silverlight</category>
            <link>http://www.rjygraham.com/archive/2009/04/05/6.aspx</link>
            <description>&lt;p&gt;I love the [Authorize()] attribute in ASP.NET MVC for 2 main reasons:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;It’s easy to use. &lt;/li&gt;    &lt;li&gt;It “feels” lightweight. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I wish Silverlight/Prism had a similar security mechanism – but it doesn’t (at least not that I’ve found). Being new to the Silverlight scene I figured I’d take a stab at creating a reusable security mechanism that could be used in a stock Silverlight or Silverlight/Prism application. &lt;/p&gt;  &lt;p&gt;The only requirements are that it must:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Be easy to use. &lt;/li&gt;    &lt;li&gt;Feel lightweight. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Having said that, I wanted to post a code snippet of a Silverlight security solution that I feel captures the 2 requirements mentioned above.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="Sandbox.Web.Shell.Shell"&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; 
    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns:clr&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System;assembly=mscorlib"&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns:local&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:Sandbox.Web.Modules.Security.Converters;assembly=Sandbox.Web.Modules.Security"&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;UserControl.Resources&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;local:AuthorizedEnabledConverter&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="ButtonEnabled"&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;local:AuthorizedVisibleConverter&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TextBlockVisible"&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;clr:String&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="Authorization"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Users=John,Jane;Roles=Administrator&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;clr:String&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;UserControl.Resources&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;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="White"&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;Grid.RowDefinitions&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;RowDefinition&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;Grid.RowDefinitions&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;Grid.ColumnDefinitions&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;ColumnDefinition&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;ColumnDefinition&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;Grid.ColumnDefinitions&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;Button&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Click Me If You Can"&lt;/span&gt; &lt;span class="attr"&gt;IsEnabled&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Source={StaticResource Authorization}, Converter={StaticResource ButtonEnabled}}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&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;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Hello World"&lt;/span&gt; &lt;span class="attr"&gt;Visibility&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Source={StaticResource Authorization}, Converter={StaticResource TextBlockVisible}}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&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;Grid&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;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h5&gt;&lt;span class="kwrd" /&gt;&lt;/h5&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[


.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; }]]&gt;&lt;/style&gt;

&lt;h3&gt;&lt;span class="kwrd" /&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span class="kwrd"&gt;The important pieces of the XAML code above are the AuthorizedEnabledConverter and AuthorizedVisibleConverter converters declared in the UserControl.Resources section and how I used them in the Binding of the IsEnabled and Visibility properties of the Button and TextBlock. For the purposes of this post, I simply declared a static string resource with hardcoded users and roles, but this could just as easily be passed in as a property of a ViewModel or handled in a Presenter or Controller. The missing part of the puzzle (and the part I’m currently working on) is how I resolve the current user’s Username and roles within the converters.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="kwrd"&gt;So what does everyone think? Is this a viable security mechanism for Silverlight? Does it stay true to the requirements of being easy to use and lightweight?&lt;/span&gt;&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/6.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/04/05/6.aspx</guid>
            <pubDate>Mon, 06 Apr 2009 01:55:18 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/6.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/04/05/6.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/6.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Part 2: Configuring the Prism.Framework.Web.Shell Project</title>
            <category>Prism</category>
            <category>Silverlight</category>
            <link>http://www.rjygraham.com/archive/2009/04/05/5.aspx</link>
            <description>&lt;p&gt;In &lt;a href="http://www.rjygraham.com/archive/2009/03/22/4.aspx" target="_blank"&gt;Part 1&lt;/a&gt; we laid the foundation of our Silverlight/Prism solution by setting up the following projects: Prism.Framework.Api, Prism.Framework.Web.Shell, Prism.Framework.Web.&lt;/p&gt;  &lt;p&gt;In Part 2 we’re going to pick up where we left off and configure our Prism.Framework.Web.Shell project for use with the Prism framework. Before we begin, let’s quickly review the prerequisites.&lt;/p&gt;  &lt;h3&gt;Prerequisites&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;You’re familiar with the Prism guidance concepts and understand why you would use it to build a Silverlight application. If you’re not familiar with Prism and it’s concepts, stop right now and read the &lt;a href="http://msdn.microsoft.com/en-us/library/dd458809.aspx" target="_blank"&gt;documentation on MSDN&lt;/a&gt;. I’ll wait for you, I promise. :) &lt;/li&gt;    &lt;li&gt;You’re an experienced C#/VB software developer. &lt;/li&gt;    &lt;li&gt;You have some exposure (or a strong interest in learning) software design patterns such as Inversion of Control (IoC), Dependency Injection (DI), Model-View-Presenter (MVP), Model-View-ViewModel (MVVM). &lt;/li&gt;    &lt;li&gt;You have &lt;a href="http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx" target="_blank"&gt;Visual Studio 2008 SP1&lt;/a&gt; installed on your system. &lt;/li&gt;    &lt;li&gt;You have &lt;a href="http://go.microsoft.com/fwlink/?LinkId=129043" target="_blank"&gt;Silverlight Tools for Visual Studio 2008 SP1&lt;/a&gt; installed on your system. &lt;/li&gt;    &lt;li&gt;You have some exposure working with Silverlight 2 (doesn’t need to be much – as long as you’re familiar with the structure of a Silverlight 2 project, XAML, and code behind). &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Compiling The Prism Libraries&lt;/h3&gt;  &lt;p&gt;We have one more house keeping chore we need to take care of before we start with overhauling the stock Silverlight project with Prism – compiling the Prism source code. Again, this is a relatively trivial task.&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff8040"&gt;&lt;strong&gt;NOTE: If you are running a 64-bit OS, substitute C:\Program Files (x86)\ for C:\Program Files\ in all file paths.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Fire up VS2008 and open the following solution (assuming you placed the Prism folder in the location suggested in &lt;a href="http://www.rjygraham.com/archive/2009/03/22/4.aspx"&gt;Part 1&lt;/a&gt;): &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\CAL\CompositeApplicationLibrary.sln.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Right-Click on the CompositeApplicationLibrary solution –&amp;gt; Rebuild Solution      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb.png" width="445" height="432" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Change the Solution Configurations from Debug to Release and then Right-Click on the CompositeApplicationLibrary solution –&amp;gt; Rebuild Solution (this is just to rebuild the assemblies under Release configuration so they’re ready for when we need them).      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_3.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_3.png" width="402" height="129" /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Now open up Windows Explorer and navigate to the following folder: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;Create a new folder and rename it to:&lt;/font&gt; Bin&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;Create two folders beneath the Bin folder:&lt;/font&gt; Debug, Release.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Now navigate to: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\CAL\Silverlight\Composite.UnityExtensions\Bin\Debug&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;Copy the following files to:&lt;/font&gt; &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\&lt;/font&gt;Bin\Debug\&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;Microsoft.Practices.Composite.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.Presentation.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.UnityExtensions.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.ServiceLocation.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Unity.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.pdb &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.Presentation.pdb &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.UnityExtensions.pdb &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.xml &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.Presentation.xml &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.UnityExtensions.xml &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Now navigate to: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\LIB\Desktop\CommonServiceLocation&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Copy the following file to: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\Bin\Debug\&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;Microsoft.Practices.ServiceLocation.XML &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Now navigate to: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\LIB\Desktop\Unity&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Copy the following file to: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\Bin\Debug\&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;Microsoft.Practices.Unity.xml &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Repeat the steps above, this time getting the files from the Release folder instead of Debug and copy them into: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\Bin\Release\&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;Configuring the Prism.Framework.Web.Shell project for Prism&lt;/h3&gt;  &lt;p&gt;Now that we have all the house keeping tasks out of the way, we can get into the good stuff – adding Prism to our solution. I learn best by doing first, understanding second, so I’m going to take that approach here. I’ll do my best to walk you through with screen shots and code snippets. Sound good?&lt;/p&gt;  &lt;h4&gt;Add New References and Code Files to the Prism.Framework.Web.Shell Project&lt;/h4&gt;  &lt;ol&gt;   &lt;li&gt;If you don’t already have the Prism.Framework solution opened in Visual Studio, go ahead and do that. &lt;/li&gt;    &lt;li&gt;Right-Click on the Prism.Framework.Web.Shell project and click Add Reference…      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_4.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_4.png" width="339" height="364" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Click on the Browse tab, then browse to the folder: &lt;font color="#0000ff"&gt;C:\Program Files\Microsoft SDKs\Prism V2\Bin\Debug\&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Select the following files:      &lt;ul&gt;       &lt;li&gt;Microsoft.Practices.Composite.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.Presentation.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Composite.UnityExtensions.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.ServiceLocation.dll &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.Unity.dll &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Click OK &lt;/li&gt;    &lt;li&gt;Add a new interface file named IShellView. &lt;/li&gt;    &lt;li&gt;Add a new class file named Bootstrapper. &lt;/li&gt; &lt;/ol&gt;  &lt;h4&gt;Modifying Our New Files&lt;/h4&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Add the following method signature to the IShellView interface:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;void ShowView()&lt;/p&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Add the following using statements to the Bootstrapper.cs file:      &lt;ul&gt;       &lt;li&gt;Microsoft.Practices.Composite.Modularity &lt;/li&gt;        &lt;li&gt;Microsoft.Practices.UnityExtensions &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Update the Bootstrapper’s signature to inherit from UnityBootrapper and then implement the abstract class.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_5.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_5.png" width="591" height="124" /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Now override the following protected methods:      &lt;ul&gt;       &lt;li&gt;ConfigureContainer &lt;/li&gt;        &lt;li&gt;GetModuleCatalog &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Change the GetModuleCatalog method to the following:      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; IModuleCatalog GetModuleCatalog()
{
     ModuleCatalog catalog = &lt;span class="kwrd"&gt;new&lt;/span&gt; ModuleCatalog();
     &lt;span class="kwrd"&gt;return&lt;/span&gt; catalog;
}&lt;/pre&gt;
    &lt;/li&gt;&lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Change the ConfigureContainer method to the following:&lt;/span&gt; &lt;/li&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ConfigureContainer()
{
    Container.RegisterType&amp;lt;IShellView, Shell&amp;gt;();
    &lt;span class="kwrd"&gt;base&lt;/span&gt;.ConfigureContainer();
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.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; }]]&gt;&lt;/style&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Change the CreateShell method to the following:&lt;/span&gt;&lt;/li&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; DependencyObject CreateShell()
{
    IShellView view = Container.Resolve&amp;lt;IShellView&amp;gt;();
    view.ShowShell();

    &lt;span class="kwrd"&gt;return&lt;/span&gt; view &lt;span class="kwrd"&gt;as&lt;/span&gt; DependencyObject;
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.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; }]]&gt;&lt;/style&gt;&lt;style type="text/css"&gt;&lt;![CDATA[
.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; }]]&gt;&lt;/style&gt;&lt;/ol&gt;

&lt;h4&gt;Modify Page.xaml&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Right-Click on Page.xaml –&amp;gt; Rename &lt;/li&gt;

  &lt;li&gt;Rename Page.xaml to Shell.xaml 
    &lt;br /&gt;

    &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_6.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_6.png" width="337" height="199" /&gt;&lt;/a&gt; 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;Right-Click on Shell.xaml –&amp;gt; View Code &lt;/li&gt;

  &lt;li&gt;Rename the class from Page to Shell 
    &lt;br /&gt;

    &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_7.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_7.png" width="437" height="189" /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;While you have the public partial class Shell open, implement the IShellView interface. &lt;/li&gt;

  &lt;li&gt;Change the ShowShell method to the following: 
    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ShowShell()
{
    Application.Current.RootVisual = &lt;span class="kwrd"&gt;this&lt;/span&gt;;
}&lt;br /&gt;&lt;/pre&gt;

    &lt;pre class="csharpcode"&gt; &lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;Shell.cs should now look like: 
    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Net;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Documents;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Input;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Media.Animation;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Shapes;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Prism.Framework.Web.Shell
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Shell : UserControl, IShellView
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Shell()
        {
            InitializeComponent();
        }

        &lt;span class="preproc"&gt;&lt;font color="#0000ff"&gt;#region&lt;/font&gt;&lt;/span&gt; IShellView Members

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ShowShell()
        {
            Application.Current.RootVisual = &lt;span class="kwrd"&gt;this&lt;/span&gt;;
        }

        &lt;span class="preproc"&gt;&lt;font color="#0000ff"&gt;#endregion&lt;/font&gt;&lt;/span&gt;
    }
}&lt;/pre&gt;
    &lt;/li&gt;&lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;

    &lt;pre class="csharpcode"&gt; &lt;/pre&gt;
    &lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Add the following namespace declaration to the root UserControl element in Shell.xaml:&lt;/span&gt; &lt;/li&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="attr"&gt;xmlns:regions&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;&lt;![CDATA[
.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; }]]&gt;&lt;/style&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Add a TextBlock element to root UserControl element in Shell.xaml and give it an arbitrary Text value (for instance, Hello World!). This is just to make sure our Shell view is loading when we run the application.&lt;/span&gt; &lt;/li&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Add the following ItemsControl element to the root UserControl element in Shell.xaml beneath the previously added TextBlock element:&lt;/span&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MainRegion"&lt;/span&gt; &lt;span class="attr"&gt;regions:RegionManager&lt;/span&gt;.&lt;span class="attr"&gt;RegionName&lt;/span&gt;&lt;span class="kwrd"&gt;="MainRegion"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Shell.xaml should now look like:&lt;span class="kwrd"&gt; 
    &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="Prism.Framework.Web.Shell.Shell"&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; 
    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns:regions&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"&lt;/span&gt;
    &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="400"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&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;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="White"&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;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Hello World!"&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;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MainRegion"&lt;/span&gt; &lt;span class="attr"&gt;regions:RegionManager&lt;/span&gt;.&lt;span class="attr"&gt;RegionName&lt;/span&gt;&lt;span class="kwrd"&gt;="MainRegion"&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;Grid&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;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;

&lt;h4&gt;&lt;span class="kwrd"&gt;Modify App.xaml.cs&lt;/span&gt;&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;span class="kwrd"&gt;Right-Click on App.xaml –&amp;gt; View Code 
      &lt;br /&gt;&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span class="kwrd"&gt;Change the Application_Startup method to the following:&lt;/span&gt; 

    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Application_Startup(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, StartupEventArgs e)
{
    Bootstrapper bootstrapper = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bootstrapper();
    bootstrapper.Run();
}&lt;/pre&gt;

    &lt;pre class="csharpcode"&gt; &lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;Press F5 to run the application, you should see the following: 
      &lt;br /&gt;

      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_8.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part2GettingstartedwithSilverlightPrism_104D2/image_thumb_8.png" width="483" height="205" /&gt;&lt;/a&gt; &lt;/p&gt;
    &lt;/li&gt;&lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;
&lt;/ol&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.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; }]]&gt;&lt;/style&gt;

&lt;h3&gt;What Did We Just Do? And Why The Heck Did We Do It?&lt;/h3&gt;

&lt;p&gt;Alright, we just did quite a bit of work so let’s break it down piece by piece – I’ll skip over adding the Prism assemblies to the Shell project because that’s pretty self explanatory.&lt;/p&gt;

&lt;p&gt;Immediately after adding the references to the Prism assemblies we added 2 new files to our project: IShellView.cs and Bootstrapper.cs. We’ll cover IShellView and the concept of using interfaces for views in a future post covering design patterns, so for now we’ll just say that creating and implementing the IShellView interface helps make our solution more testable.&lt;/p&gt;

&lt;p&gt;The really important bits here are in Bootstrapper.cs, which is essentially the backbone of our Prism solution. In Bootstrapper.cs we overrode the CreateShell, ConfigureContainer, and GetModuleCatalog methods of the UnityContainer class from which we inherited – let’s take a closer look.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd490825.aspx" target="_blank"&gt;Modularity&lt;/a&gt; is one of the core design concepts of the Prism framework and a composite application. In the GetModuleCatalog method we’re essentially setting up the capability for our application to specify which modules will be used. However, as of right now all we’re doing is instantiating and returning an empty ModuleCatalog instance. In the next post we’ll be adding a module to the solution and will therefore need to add it to the ModuleCatalog - which we’ll do via static code.&lt;/p&gt;

&lt;p&gt;Let’s now shift our focus to the ConfigureContainer method. In this method we’re registering components with the dependency injection container for retrieval at a later time. The IShellView interface is specified as the type that will be requested, and the Shell class is specified as the type that will actually be returned. At first glance this may not seem like a big deal, but if you think about it, it’s actually quite important. Since we’re using interfaces to request types, we’re not tied to any specific implementation and can therefore swap out functionality as needed. The interfaces will also come in handy when it’s time to write automated unit tests – therefore making our application easier to maintain and hopefully producing a higher quality product.&lt;/p&gt;

&lt;p&gt;In the CreateShell method we resolved the Shell class by requesting an IShellView from the dependency injection container. Once we’ve resolved the Shell, we call the ShowShell method and then return the Shell as a DependencyObject. There’s nothing too magical happening in this method, but I’d like to note that creating the Shell in the bootstrapper class aids in testability since we can mock the Shell in a unit testing framework.&lt;/p&gt;

&lt;p&gt;Moving along to the Shell, the first thing we did was rename Page.xaml to Shell.xaml. This is merely for convention and we could have just as easily left Page.xaml alone. We then implemented the ShowShell method from the IShellView interface which sets the Application’s RootVisual equal to the instance of the Shell. In the Shell.xaml file we then added the regions namespace so we could add the ItemsControl which is the container control for our MainRegion region. Of course, we don’t have any views to inject into the MainRegion right now - but we’ll be adding one in the next post.&lt;/p&gt;

&lt;p&gt;Finally, we modified the Application_Startup method of the App class to instantiate an instance of our bootstrapper class and call it’s Run method. The Run method essentially starts the process of configuring the container, configuring the region mappings, creating the shell, and initializing the modules. These activities directly relate to the methods we overrode when we created the Bootstrapper class which is precisely why we needed to override the default implementation of those methods. One last thing to point out. If you have a keen eye, you probably noticed the code we replaced within the Application_Startup method is nearly identical to the code we placed within the ShowShell method of the Shell class. By doing this we’re simply removing the responsibility of displaying the Shell as the application’s visual root from the App class and placing it in the hands of the Shell class which is more aligned with using the bootstrapper process.&lt;/p&gt;

&lt;p&gt;This was a long but essential post and we’re finally ready to begin creating modules and add “real” functionality to our app. And that’s exactly where we’ll pick up in Part 3.&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/5.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/04/05/5.aspx</guid>
            <pubDate>Mon, 06 Apr 2009 00:51:57 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/5.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/04/05/5.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/5.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Part 1: Setting up our Silverlight/Prism Solution</title>
            <category>Silverlight</category>
            <category>Prism</category>
            <category>WCF</category>
            <link>http://www.rjygraham.com/archive/2009/03/22/4.aspx</link>
            <description>&lt;p&gt;As I mentioned in my &lt;a href="http://www.rjygraham.com/archive/2009/03/22/2.aspx" target="_blank"&gt;very first blog post&lt;/a&gt;, I intend on writing a series of posts about using Silverlight with &lt;a href="http://compositewpf.codeplex.com/" target="_blank"&gt;Prism&lt;/a&gt; – something similar to &lt;a href="http://silverlight.net/learn/appcorner/adventureworkspt1.aspx?pt=1" target="_blank"&gt;The Application Corner with Tim Heuer&lt;/a&gt;. In order to get a jump start on the series, I thought it’d be a good idea to get the “setup” post done and out of the way. So without further ado…&lt;/p&gt;  &lt;h3&gt;Prerequisites&lt;/h3&gt;  &lt;p&gt;In order to follow along with this post and series, I assume the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;You’re familiar with the Prism guidance concepts and understand why you would use it to build a Silverlight application. If you’re not familiar with Prism and it’s concepts, stop right now and read the &lt;a href="http://msdn.microsoft.com/en-us/library/dd458809.aspx" target="_blank"&gt;documentation on MSDN&lt;/a&gt;. I’ll wait for you, I promise. :)&lt;/li&gt;    &lt;li&gt;You’re an experienced C#/VB software developer. &lt;/li&gt;    &lt;li&gt;You have some exposure (or a strong interest in learning) software design patterns such as Inversion of Control (IoC), Dependency Injection (DI), Model-View-Presenter (MVP), Model-View-ViewModel (MVVM). &lt;/li&gt;    &lt;li&gt;You have &lt;a href="http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx"&gt;Visual Studio 2008 SP1&lt;/a&gt; installed on your system. &lt;/li&gt;    &lt;li&gt;You have &lt;a href="http://go.microsoft.com/fwlink/?LinkId=129043"&gt;Silverlight Tools for Visual Studio 2008 SP1&lt;/a&gt; installed on your system. &lt;/li&gt;    &lt;li&gt;You have some exposure working with Silverlight 2 (doesn’t need to be much – as long as you’re familiar with the structure of a Silverlight 2 project, XAML, and code behind). &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Ok, now that I have the obligatory prereqs out of the way, let’s get started.&lt;/p&gt;  &lt;h3&gt;Setting up our Silverlight/Prism Solution&lt;/h3&gt;  &lt;ol&gt;   &lt;li&gt;For starters we need to install Prism on our local machine – which is relatively trivial:&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Download prism from this &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=fa07e1ce-ca3f-4b9b-a21b-e3fa10d013dd&amp;amp;DisplayLang=en" target="_blank"&gt;page&lt;/a&gt;. NOTE: You may also want to download the documentation - I prefer to use the online docs at: &lt;a href="http://msdn.microsoft.com" target="_blank"&gt;msdn.microsoft.com&lt;/a&gt;. &lt;/li&gt;      &lt;li&gt;Run the self extracting file and extract the files to a folder named &lt;strong&gt;Prism V2&lt;/strong&gt; &lt;/li&gt;      &lt;li&gt;Move the &lt;strong&gt;Prism V2&lt;/strong&gt; folder extracted the files to &lt;strong&gt;C:\Program Files\Microsoft SDKs\&lt;/strong&gt; (or &lt;strong&gt;C:\Program Files (x86)\Microsoft SDKs\&lt;/strong&gt; if you’re running a 64-bit OS).         &lt;br /&gt;&lt;font color="#000080"&gt;NOTE: You don’t have to move the Prism V2 folder to the Microsoft SDKs folder, I just like to keep all my SDK stuff located in the a common place and the Microsoft SDKs folder makes sense.&lt;/font&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Alright, now fire up VS2008 and create a blank Visual Studio Solution named &lt;strong&gt;Prism.Framework&lt;/strong&gt;.      &lt;br /&gt;&lt;font color="#000080"&gt;NOTE: The names you choose for your solutions and projects are arbitrary - it’ll just make things easier for you to use the names I do, especially if you’ll be following along with this blog series.       &lt;br /&gt;&lt;/font&gt;      &lt;br /&gt; &lt;a href="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_thumb.png" width="644" height="436" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;In the Solution Explorer, right-click on the Prism.Framework solution and click Add –&amp;gt; New Project… –&amp;gt; Visual C# –&amp;gt; Web –&amp;gt; WCF Service Application. Use &lt;strong&gt;Prism.Framework.Api&lt;/strong&gt; as the project name. Click OK.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_3.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_thumb_3.png" width="644" height="414" /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;In the Solution Explorer, right-click on the Prism.Framework solution and click Add –&amp;gt; New Project… –&amp;gt; Visual C# –&amp;gt; Silverlight –&amp;gt; Silverlight Application. Use &lt;strong&gt;Prism.Framework.Shell&lt;/strong&gt; as the project name. Click OK.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_4.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_thumb_4.png" width="644" height="413" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;In the Add Silverlight Application dialog window that pops up after step 4, choose Add a new ASP.NET Web project to the solution to host Silverlight, Project Type: &lt;strong&gt;ASP.NET Web Application Project&lt;/strong&gt;, and use &lt;strong&gt;Prism.Framework.Web&lt;/strong&gt; as the name.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_5.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://rjygraham.com/Images/Part1SettingupourSilverlightPrismSolutio_C562/image_thumb_5.png" width="459" height="410" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p&gt;And that’s it! Let’s look at what we just did:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Created a Prism.Framework solution to house all the projects related to this blog series.&lt;/li&gt;    &lt;li&gt;Created the Prism.Framework.Api WCF project which will serve as the means of communicating with backend systems. This will be deployed to the web server as: http://api.yourdomain.com.&lt;/li&gt;    &lt;li&gt;Created the Prism.Framework.Web.Shell project. This project will serve as the application shell into which we’ll load our application’s various modules. &lt;/li&gt;    &lt;li&gt;Created the Prism.Framework.Web project to host the Silverlight shell. This will eventually be deployed to the web server as: http://www.yourdomain.com.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now you might be asking yourself, why can’t we just use the Prism.Framework.Web project to host both the Silverlight shell and WCF services projects? We could certainly do that, but by putting the WCF services in their own project, we decouple those services from the web site hosting the Silverlight shell, therefore making them logically available to other applications. Plus, now we have a reason to implement a Silverlight clientaccesspolicy.xml file in a future post. :)&lt;/p&gt;  &lt;p&gt;In the next post we’ll configure the Prism.Framework.Web.Shell project to use the Prism framework.&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/4.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/03/22/4.aspx</guid>
            <pubDate>Sun, 22 Mar 2009 23:11:54 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/4.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/03/22/4.aspx#feedback</comments>
            <slash:comments>21</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/4.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Subtext Sitemap for Google Sitemaps</title>
            <link>http://www.rjygraham.com/archive/2009/03/22/3.aspx</link>
            <description>&lt;p&gt;This wasn’t in the documentation anywhere (at least I couldn’t find it), but if you want to add your Subtext powered blog to Google Sitemaps you need to reference the following URL: &lt;a href="http://www.yourdomainhere.com/sitemap.ashx"&gt;http://www.yourdomainhere.com/sitemap.ashx&lt;/a&gt;. So for my blog the URL is: &lt;a href="http://www.rjygraham.com/sitemap.ashx"&gt;http://www.rjygraham.com/sitemap.ashx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Just a heads up to everyone.&lt;/p&gt;&lt;img src="http://www.rjygraham.com/aggbug/3.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Graham</dc:creator>
            <guid>http://www.rjygraham.com/archive/2009/03/22/3.aspx</guid>
            <pubDate>Sun, 22 Mar 2009 17:54:17 GMT</pubDate>
            <wfw:comment>http://www.rjygraham.com/comments/3.aspx</wfw:comment>
            <comments>http://www.rjygraham.com/archive/2009/03/22/3.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://www.rjygraham.com/comments/commentRss/3.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>