<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.pluralsight-training.net/community/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Security Briefs</title><link>http://www.pluralsight-training.net/community/blogs/keith/default.aspx</link><description>by Keith Brown</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>SoCal Code Camp</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/28/socal-code-camp.aspx</link><pubDate>Mon, 28 Jun 2010 19:26:59 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:90092</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=90092</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/28/socal-code-camp.aspx#comments</comments><description>&lt;p&gt;It was great meeting all of you at the camp! Thanks for coming to my talk, “Get a Whiff of WIF”. The slides and demos can be found &lt;a href="http://pluralsight-free.s3.amazonaws.com/keith-brown/shows/2010-06-socal-code-camp.zip"&gt;here&lt;/a&gt;. If you attended the camp, don’t forget to activate your free 7-day subscription to &lt;a href="http://www.pluralsight-training.net/microsoft/olt/default.aspx"&gt;Pluralsight &lt;em&gt;On-Demand!&lt;/em&gt;&lt;/a&gt; You’ll be able to see *all* of our courses without restriction!&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=90092" width="1" height="1"&gt;</description></item><item><title>Keith Brown’s TechEd NA 2010 Session Demos</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/12/keith-brown-s-teched-na-2010-session-demos.aspx</link><pubDate>Sat, 12 Jun 2010 22:23:42 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:89714</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=89714</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/12/keith-brown-s-teched-na-2010-session-demos.aspx#comments</comments><description>&lt;p&gt;I was fortunate to be able to tag team a talk at TechEd New Orleans with &lt;a href="http://www.pluralsight-training.net/community/blogs/aaron/default.aspx"&gt;Aaron Skonnard&lt;/a&gt; this week, and I wanted to post my bits from the demos we did.&lt;/p&gt;  &lt;p&gt;There were three parts to my demo. The first part was where Aaron added in an attribute on his Presentation Feed service to require a claim before granting access to the feed. You can get the code for his service and my WCF behavior attribute from his demos &lt;a href="http://www.pluralsight-training.net/community/blogs/aaron/archive/2010/06/12/aaron-skonnard-s-teched-na-2010-session-demos.aspx"&gt;here&lt;/a&gt;. The code for the client that authenticates with ACS to get a token to send in the Authorization header to Aaron’s service can be found in my demos (below). It’s in the PresentationFeedClient folder.&lt;/p&gt;  &lt;p&gt;The second part of my demo used a simple string reverser service that I built in ASP.NET MVC. Once again, I simply authenticated directly with ACS, got a token, and sent it to the service as part of the Authorization header.&lt;/p&gt;  &lt;p&gt;The third part of my demo simulated an enterprise single sign on. I used &lt;a href="http://blogs.msdn.com/b/justinjsmith/archive/2009/11/14/acs-saml-adfs-v2-sample.aspx"&gt;Justin Smith’s “mini ADFS” simulator&lt;/a&gt; to issue a SAML token to my client, simulating a logon request to a real ADFS federation server in a domain. I then sent this SAML token up to ACS and got back a SWT (Simple Web Token) which I sent to my string reverser service, which allowed me in.&lt;/p&gt;  &lt;p&gt;The service and client for these last two parts can also be found in the StringReverser folder of my demos (below). I also included a copy of Justin’s MiniADFS server as part of the solution. I hope he doesn’t mind! You’ll need to install the &lt;a href="http://www.microsoft.com/Downloads/details.aspx?familyid=C148B2DF-C7AF-46BB-9162-2C9422208504&amp;amp;displaylang=en"&gt;Windows Identity Foundation SDK&lt;/a&gt; to run this third demo, as that’s where the SAML and WS-Trust support comes from.&lt;/p&gt;  &lt;p&gt;I used the sample ACS Management Browser from the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=39856a03-1490-4283-908f-c8bf0bfad8a5"&gt;Azure AppFabric SDK&lt;/a&gt; to set up a very simple policy in ACS to issue the tokens needed by the services. I included a copy of the policy in the policy.xml file. Nothing fancy here – just simple rules based on issuer claims.&lt;/p&gt;  &lt;p&gt;Download my demos &lt;a href="http://pluralsight-free.s3.amazonaws.com/keith-brown/shows/2010-06-TechEd-ACS-demos.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Thanks to those who turned in evaluations. Our talk was number three in our track thanks to you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=89714" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Security/default.aspx">Security</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Identity/default.aspx">Identity</category></item><item><title>Dynamically emitting types for unit tests</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/02/dynamically-emitting-types-for-unit-tests.aspx</link><pubDate>Thu, 03 Jun 2010 02:47:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:89360</guid><dc:creator>keith-brown</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=89360</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/02/dynamically-emitting-types-for-unit-tests.aspx#comments</comments><description>&lt;p&gt;I&amp;rsquo;m building a view engine for ASP.NET MVC 2 that locates views based on the type names of the controllers. To unit test the bits that construct a path from a namespace, I needed to have a bunch of different types of controllers, and using actual types was clearly going to get messy, so I synthesized my own dynamic types using Reflection.Emit. This particular example is hardcoded to produce classes that derive from System.Web.Mvc.Controller, but it&amp;rsquo;s a great start for anyone who wants to synthesize types for whatever reason. It was well worth 15 minutes of research and coding. Kudos to the .NET team for making it so easy!&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example of usage:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;var factory = &lt;span class="kwrd"&gt;new&lt;/span&gt; ControllerTypeFactory();
var type = factory.MakeControllerType(&lt;span class="str"&gt;&amp;quot;Foo.Bar.MyController&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;The output from this call allows you to avoid having to write this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Foo.Bar
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MyController : Controller { }
}&lt;/pre&gt;
&lt;p&gt;If you want an instance instead of just the type, call MakeController instead, which simply adds a call to Activator.CreateInstance() on the dynamically created type.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the code. Note that it creates a &amp;ldquo;RunAndCollect&amp;rdquo; assembly, which is great for simple cases like this because the assembly will be unloaded from the domain automatically once everything in it is collected. It&amp;rsquo;s making my unit tests green, which is making me smile.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ControllerTypeFactory
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; AssemblyBuilder assemblyBuilder;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; ControllerTypeFactory()
    {
        var assemblyName = &lt;span class="kwrd"&gt;new&lt;/span&gt; AssemblyName(Guid.NewGuid().ToString());
        assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,AssemblyBuilderAccess.RunAndCollect);
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Type MakeControllerType(&lt;span class="kwrd"&gt;string&lt;/span&gt; controllerTypeName)
    {
        var moduleBuilder = assemblyBuilder.DefineDynamicModule(&lt;span class="str"&gt;&amp;quot;module&amp;quot;&lt;/span&gt;);
        &lt;span class="kwrd"&gt;const&lt;/span&gt; TypeAttributes typeAttributes = TypeAttributes.Public | TypeAttributes.Class;
        var parentType = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Controller);
        var typeBuilder = moduleBuilder.DefineType(controllerTypeName, typeAttributes, parentType);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; typeBuilder.CreateType();
    }

    &lt;span class="kwrd"&gt;internal&lt;/span&gt; ControllerBase MakeController(&lt;span class="kwrd"&gt;string&lt;/span&gt; controllerTypeName)
    {
        var controllerType = MakeControllerType(controllerTypeName);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; (ControllerBase)Activator.CreateInstance(controllerType);
    }
}&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=89360" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Types vs. Strings to identify controllers and simplify Areas in ASP.NET MVC 2</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/02/types-vs-strings-to-identify-controllers-and-simplify-areas-in-asp-net-mvc-2.aspx</link><pubDate>Thu, 03 Jun 2010 00:50:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:89359</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=89359</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/06/02/types-vs-strings-to-identify-controllers-and-simplify-areas-in-asp-net-mvc-2.aspx#comments</comments><description>&lt;p&gt;Ever since I started working out the RESTful routing strategy we&amp;rsquo;ll be using for our MVC apps at Pluralsight, I&amp;rsquo;ve been trying to avoid identifying controllers with strings in places like HtmlHelpers.ActionLink. It occurred to me early on that I&amp;rsquo;d much rather use type names to identify resources and controllers rather than string.&lt;/p&gt;
&lt;p&gt;If you have a WidgetController, why pass controller=&amp;ldquo;Widget&amp;rdquo; when you could specify the type of the controller instead? Then you&amp;rsquo;d see compile errors early, as opposed to having links with empty href elements because the HtmlHelper couldn&amp;rsquo;t find a matching route because you misspelled a controller name.&lt;/p&gt;
&lt;p&gt;You could solve this particular problem by using constants (controller = Controllers.Widget), I suppose. But then when you look at how Areas work, it sure would be nice having the type as part of the route.&lt;/p&gt;
&lt;p&gt;I suppose the reason controller names are passed around as strings so much is because of the default routes that ASP.NET MVC gives you when you run the wizard: {controller}/{id}/{action}. But for someone who wants to take a more RESTful approach, you don&amp;rsquo;t want this style of routing anyway, and you&amp;rsquo;ll be adding a bunch of custom routes instead of trying to use one generic URL pattern for routing.&lt;/p&gt;
&lt;p&gt;In large systems, {controller} isn&amp;rsquo;t enough to identify a controller anyway. You need to add areas to ensure uniqueness of controller names. Which leads me to the subject of this post (finally!) I&amp;rsquo;m wondering if anyone can think of any major drawback to simply removing {controller} from the values used in RouteData.Values and replace it with {controllerType} in RouteData.DataTokens. In one fell swoop you eliminate both controller names and area names from the equation.&lt;/p&gt;
&lt;p&gt;In large systems where you care about testing, you&amp;rsquo;re likely to be using ViewModels and modeling links to make them testable. So you won&amp;rsquo;t be using Html.ActionLink anyway, and it&amp;rsquo;s very natural to use controller types to build the models for links to controllers that you depend on.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve got a prototype of this working now, and it allows me to put my controllers wherever I like (they don&amp;rsquo;t have to be in the Controllers folder). My unit tests for resolving incoming requests and outgoing URL generation are all green.&lt;/p&gt;
&lt;p&gt;My next step is to build a custom view engine that looks for views based on the controller type. Once that&amp;rsquo;s wrapped up, I should have very natural support for &amp;ldquo;areas&amp;rdquo; that&amp;rsquo;s based on the types of the controllers, with a hierarchy that follows the namespace structure of the controllers, which should naturally resolve any naming conflicts that could arise. My initial thought about view resolution is that it&amp;rsquo;d be nice to be able to map an arbitrary prefix of the controller type (e.g. the first bit of the namespace) onto a root folder for the &amp;ldquo;area&amp;rdquo; then have the namespace-driven search algorithm take over from there, following the rest of the namespace down the folder tree from the &amp;ldquo;area&amp;rdquo; root. Might also be nice to have the view engine be able to pick up shared views from anywhere up the hierarchy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request to the MVC team:&lt;/strong&gt; I had to make one minor change to MvcHandler to be able to get ASP.NET MVC 2 to work this way. I changed MvcHandler.ProcessRequestInit from [private] to [protected virtual]. This allowed me to reuse the vast majority of MvcHandler (the async stuff would be a *** to reimplement). This seems like a really useful extensibility point.&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;b&gt;Update (3 Jun 2010)&lt;/b&gt;: My view engine is complete, and it&amp;#39;s working like a charm. No more worrying about &amp;quot;areas&amp;quot; - I get a nice hierarchical site based on the structure of the namespaces of the types that I use in my application. If I run into any problems I&amp;#39;ll post them here, but it looks like this is a feasible way to implement a RESTful routing scheme.&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=89359" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Controlling TemplateDepth in ASP.NET MVC 2 Templates</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/31/controlling-templatedepth-in-asp-net-mvc-2-templates.aspx</link><pubDate>Mon, 31 May 2010 17:43:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:88996</guid><dc:creator>keith-brown</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=88996</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/31/controlling-templatedepth-in-asp-net-mvc-2-templates.aspx#comments</comments><description>&lt;p&gt;In my last &lt;a href="http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/29/dynamically-structured-viewmodels-in-asp-net-mvc.aspx"&gt;post&lt;/a&gt;, I talked about how convenient it is to use MVC 2 templates to display data. I&amp;rsquo;ve been trying to use similar ideas to construct generic forms, but I&amp;rsquo;m running into a problem that I&amp;rsquo;m hoping there&amp;rsquo;s an easy way to fix.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve built a very simple example to demonstrate what I&amp;rsquo;m seeing: a Widget controller that allows you to Create new Widgets. I&amp;rsquo;m using the default route, nothing special. But I&amp;rsquo;m using view models, not domain models. Here they are:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CreateWidgetPage
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SummaryOfExistingWidgets;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; CreateWidgetForm TheForm;
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CreateWidgetForm
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Color { get; set; }
}&lt;/pre&gt;
&lt;p&gt;The page I display when you GET /Widget/Create includes more than just a form. I&amp;rsquo;ve got some display-only details that I want to show the user when she&amp;rsquo;s about to create a widget. It doesn&amp;rsquo;t matter what it is, the point is that it&amp;rsquo;s not something that&amp;rsquo;s logically part of the form that I want posted back.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the interesting part of the Create view, which relies on &lt;a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html"&gt;Brad&amp;rsquo;s tabular Object.ascx editor template&lt;/a&gt; to display a simple editable table for Name and Color:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;: Model.SummaryOfExistingWidgets &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&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;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Create&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h2&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;form&lt;/span&gt; ...&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;= Html.EditorFor(m =&amp;gt; m.TheForm) &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&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;input&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;submit&amp;#39;&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;Create&amp;#39;&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;div&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;form&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;And the controller&amp;rsquo;s Create method that processes the form:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Create(CreateWidgetForm formModel) 
{
   &lt;span class="rem"&gt;// ...&lt;/span&gt;
}&lt;/pre&gt;
&lt;p&gt;The ViewModel that is posted to Create has null values for both Name and Color. Why? Because the EditorFor helper is encoding the scoping element, &amp;ldquo;TheForm&amp;rdquo;, as a prefix on the names of the properties on the view model. If I inspect the HTML that is rendered with a GET to /Widget/Create, the Name property is represented like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;input&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TheForm.Name&amp;quot;&lt;/span&gt; ... &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Clearly this isn&amp;rsquo;t going to bind well to CreateWidgetForm, which knows about a &amp;ldquo;Name&amp;rdquo;, not &amp;ldquo;TheForm.Name&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;In an effort to divorce CreateWidgetForm from its scope, I tried this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt; var theForm = Model.TheForm; &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;
&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;= Html.EditorFor(m =&amp;gt; theForm) &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This didn&amp;rsquo;t help. The variable, &amp;ldquo;theForm&amp;rdquo;, ended up being used as the scope:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;input&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;theForm.Name&amp;quot;&lt;/span&gt; ... &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;I could see how someone using domain models directly in their views wouldn&amp;rsquo;t run into this problem. GET on the controller&amp;rsquo;s Create would return a Widget, say, and POST to the controller&amp;rsquo;s Create would send that exact same thing back. There&amp;rsquo;s no need for nesting the way I&amp;rsquo;ve done it here.&lt;/p&gt;
&lt;p&gt;It feels like what I need is a way to tell EditorFor that I want a new root. Don&amp;rsquo;t pay attention to the fact that TheForm is a property on some bigger object. I want TemplateDepth = 1 when we drill into EditorFor in the above examples. There&amp;rsquo;s probably some super easy way to do this that I&amp;rsquo;m just not finding.&lt;/p&gt;
&lt;p&gt;Indeed what I&amp;rsquo;m trying to achieve with ViewModels goes beyond the simplified example I&amp;rsquo;ve used above. I&amp;rsquo;m thinking it would be quite nice to have a very generic template for a create form. Something like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CreateForm
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PrettyNameForTheThingWeAreAboutToCreate;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; FormModel;
}&lt;/pre&gt;
&lt;p&gt;Coupled with a display template that looks something like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="asp"&gt;&amp;lt;%@ Control Language=&amp;quot;C#&amp;quot; Inherits=&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;CreateForm&amp;gt;&amp;quot; %&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h2&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Create &lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;: Model.PrettyNameForTheThingWeAreAboutToCreate&lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h2&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;form&lt;/span&gt; ...&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;= Html.EditorFor(m =&amp;gt; m.FormModel) &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&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;input&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;submit&amp;#39;&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;#39;Create&amp;#39;&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;div&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;form&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;I searched quite a bit to see if anyone else had posted about this issue and didn&amp;rsquo;t find anything, but I can&amp;rsquo;t be the first to run into this. What am I missing?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PROBLEM SOLVED (Thanks Brad :-)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The solution in my case is to use the overloaded version of EditorFor which allows you to control the prefix:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;= Html.EditorFor(m =&amp;gt; m.FormModel, null, &amp;quot;&amp;quot;) &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Worked like a charm!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=88996" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Dynamically Structured ViewModels in ASP.NET MVC</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/29/dynamically-structured-viewmodels-in-asp-net-mvc.aspx</link><pubDate>Sat, 29 May 2010 17:26:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:88366</guid><dc:creator>keith-brown</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=88366</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/29/dynamically-structured-viewmodels-in-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;We started building our website back in 2004, when ASP.NET WebForms were all the rage. I&amp;rsquo;ve finally bitten the bullet and started integrating MVC into our website so that going forward, we&amp;rsquo;ll have a cleaner architecture that allows for better testability, separation of concerns, etc. This transition has been a fun and challenging one.&lt;/p&gt;
&lt;p&gt;As part of this effort, I&amp;rsquo;ve done a lot of experimenting with different ways of implementing testable, maintainable views. There are a lot of good threads out there that touch on this. Here are a few that I happened to read this morning:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codeclimber.net.nz/archive/2009/10/27/12-asp.net-mvc-best-practices.aspx"&gt;http://codeclimber.net.nz/archive/2009/10/27/12-asp.net-mvc-best-practices.aspx&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx"&gt;http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx&lt;/a&gt;    &lt;br /&gt;&lt;a href="http://www.arrangeactassert.com/asp-net-mvc-view-best-practices-keep-logic-out-of-your-views/"&gt;http://www.arrangeactassert.com/asp-net-mvc-view-best-practices-keep-logic-out-of-your-views/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A comment in the last thread by Jaime prompted me to write this post. I&amp;rsquo;m still not completely settled on the details of the techniques I think will work best for us at Pluralsight, but some ideas are definitely crystallizing, so I figured I&amp;rsquo;d jot them down here.&lt;/p&gt;
&lt;p&gt;For one thing, I&amp;rsquo;ve come to the conclusion that using ViewModels is pretty critical for us, since I want to be able to write automated tests that assure me that the dynamic data I want rendered is likely to actually be rendered. And I want those tests to be exposed to precisely the data that&amp;rsquo;s going to be rendered in the view &amp;ndash; no more and no less. Using domain models directly in views feels like a nice shortcut, but doesn&amp;rsquo;t lead to this outcome except in very simple cases.&lt;/p&gt;
&lt;p&gt;Another goal of mine is to eliminate *all* logic from the views themselves so the views become simply a way to interleave HTML tags with dynamic content.&lt;/p&gt;
&lt;p&gt;One of the first habits I worked on breaking was including &amp;ldquo;if&amp;rdquo; statements in views to manage optional sections. I used a lot of asp:Panel controls in my WebForm days, and it felt pretty natural to replace those panels with &amp;ldquo;if&amp;rdquo; statements in the view. After writing a couple of views this way, I quickly realized I was not going to get the level of testability I wanted. So instead of an &amp;ldquo;if&amp;rdquo; in the view checking a flag to see if an optional section should be rendered, I now take that section of the view and make another view model for it. Here&amp;rsquo;s a view model for showing a pencil with an optional erasor:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SampleViewModels
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ShowPencil
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Brand { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Erasor Erasor { get; set; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Erasor
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Color { get; set; }
    }
}&lt;/pre&gt;
&lt;p&gt;Once ShowPencil is constructed, my automated tests can walk over the structure and assert that Erasor is null or not based on the scenario I&amp;rsquo;m testing. To render the Erasor, I use a partial view, but I don&amp;rsquo;t use an &amp;ldquo;if&amp;rdquo; statement, as you&amp;rsquo;ll see later.&lt;/p&gt;
&lt;p&gt;I used a lot of asp:MultiView controls in my WebForms days. Now if I have a section of the view that needs to render one thing or another depending on business logic, I use a very similar approach to the Erasor, except I more loosely type the link to the child view model, such as I do with Mechanism below:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SampleViewModels
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ShowPencilSharpener
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Brand { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Mechanism { get; set; }
    }
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ElectricSharpeningMechanism
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Voltage { get; set; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MechanicalSharpeningMechanism
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; ArmLength { get; set; }
    }
}&lt;/pre&gt;
&lt;p&gt;These techniques allow me to easily test right under the surface of my views. I say &amp;ldquo;easily&amp;rdquo; because it&amp;rsquo;s conceptually easy, but as business logic gets more complicated and views have more optional features, tests get more complicated as well, but that&amp;rsquo;s the price you pay for complicated business logic.&lt;/p&gt;
&lt;p&gt;Now the only trick is to build a set of views and partial views that can render these dynamically structured view models. It turns out the templating features[1] introduced in ASP.NET MVC 2 work very nicely for this. For example, here&amp;rsquo;s a what a partial view for ShowPencilSharpener might look like:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;lt;%@ Control Language=&lt;span class="str"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; Inherits=&lt;span class="str"&gt;&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;SampleViewModels.ShowPencilSharpener&amp;gt;&amp;quot;&lt;/span&gt; %&amp;gt;

&amp;lt;div&amp;gt;
Brand: &amp;lt;%: Model.Brand %&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;%= Html.DisplayFor(model =&amp;gt; model.Mechanism) %&amp;gt;&lt;/pre&gt;
&lt;p&gt;DisplayFor won&amp;rsquo;t show anything if model.Mechanism is null. But if there&amp;rsquo;s something there, it will use a well defined template resolution strategy[2] to find an appropriate partial view to use. And the view selected depends on the type of object that my controller (or better yet, my view model builder) put into the Mechanism property.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s say my view model used a MechanicalSharpeningMechanism. I write a custom display template (which is really just a partial view) so I can control how that section of the view should look. Another nice feature of breaking things up like this is that if any other view model uses MechanicalSharpeningMechanism, I can easily reuse that partial view for rendering that part of the view model, if it makes sense to do so. Here&amp;rsquo;s what that partial view might look like:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;lt;%@ Control Language=&lt;span class="str"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; Inherits=&lt;span class="str"&gt;&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;SampleViewModels.MechanicalSharpeningMechanism&amp;gt;&amp;quot;&lt;/span&gt; %&amp;gt;

&amp;lt;div&amp;gt;
Arm length: &amp;lt;%: Model.ArmLength %&amp;gt; inches
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;This sort of view model composition seems really powerful to me. This morning I&amp;rsquo;m experimenting with new ways of generating forms based on this idea.&lt;/p&gt;
&lt;p&gt;Huge kudos to Brad Wilson for taking the time to walk us all through MVC 2 templates. His lucid explanation made my life much easier when I went searching for a way to render these dynamically structured view models.&lt;/p&gt;
&lt;p&gt;[1] &lt;a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html"&gt;http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html&lt;/a&gt; 
  &lt;br /&gt;[2] &lt;a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html"&gt;http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=88366" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>How to programmatically change the physical directory for a web app in IIS 7.x</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/21/how-to-programmatically-change-the-physical-directory-for-a-web-app-in-iis-7-x.aspx</link><pubDate>Fri, 21 May 2010 14:30:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:78608</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=78608</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/05/21/how-to-programmatically-change-the-physical-directory-for-a-web-app-in-iis-7-x.aspx#comments</comments><description>&lt;p&gt;There&amp;rsquo;s lots of info out there on using Microsoft.Web.Administration to configure IIS programmatically. I personally found most of it rather confusing, and I spent way too much time trying to figure this out, calling GetApplicationHostConfiguration, etc.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a dead simple way to do this that I finally found.&lt;/p&gt;
&lt;p&gt;Notes about this code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The collections return null if they don&amp;rsquo;t have the thing you are looking for. I&amp;rsquo;m not checking for that in this sample code. &lt;/li&gt;
&lt;li&gt;Don&amp;#39;t forget to include a slash in front of your app name. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; Edit later same day: Updated code to be more robust by not assuming first vdir is root. Now the code searches for a vdir named &amp;quot;/&amp;quot; under the app.   &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; Microsoft.Web.Administration;
&lt;span class="kwrd"&gt;class&lt;/span&gt; Program
{
    &lt;span class="rem"&gt;// add reference to System.Web&lt;/span&gt;
    &lt;span class="rem"&gt;// and %WINDIR%\system32\inetsrv\Microsoft.Web.Administration.dll&lt;/span&gt;
    &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main()
    {
        &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; WebsiteName = &lt;span class="str"&gt;&amp;quot;Default Web Site&amp;quot;&lt;/span&gt;;
        &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; AppName = &lt;span class="str"&gt;&amp;quot;/test&amp;quot;&lt;/span&gt;; &lt;span class="rem"&gt;// Note: starts with slash&lt;/span&gt;
        &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; NewPhysicalPath = &lt;span class="str"&gt;@&amp;quot;c:\temp\newDir&amp;quot;&lt;/span&gt;;

        &lt;span class="kwrd"&gt;using&lt;/span&gt; (var serverManager = &lt;span class="kwrd"&gt;new&lt;/span&gt; ServerManager())
        {
            var site = serverManager.Sites[WebsiteName];
            var app = site.Applications[AppName];
            var vdir = FindAppVdir(app);
            vdir.PhysicalPath = NewPhysicalPath;
            serverManager.CommitChanges();
        }
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; VirtualDirectory FindAppVdir(Application app)
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; app
            .VirtualDirectories
            .FirstOrDefault(vdir =&amp;gt; vdir.Path == &lt;span class="str"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=78608" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Question to Software Designers: IUser</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/04/08/question-to-software-designers-iuser.aspx</link><pubDate>Thu, 08 Apr 2010 23:09:11 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:76009</guid><dc:creator>keith-brown</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=76009</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/04/08/question-to-software-designers-iuser.aspx#comments</comments><description>&lt;p&gt;Even as Web Single Sign On is gaining more and more traction, there’s still churn. I would much prefer to isolate my application developers from the details of whatever library I happen to be using today to get details about my user.&lt;/p&gt;  &lt;p&gt;ASP.NET developers are used to getting an IPrincipal (and from that, an IIdentity) from HttpContext.User, WCF’s SecurityContext, etc. But modern web SSO libraries offer more than just the Name and IsInRole() query that these interfaces deliver. And as much as Microsoft may claim that IClaimsIdentity from the Windows Identity Foundation (WIF) is the LAST identity interface we’ll ever see, I’m doubtful. There’s a LOT of churn in the identity space right now. And even if there weren’t a lot of churn, I don’t think I’d want to have my developers worrying about which URI (ClaimType) they should search for to get the user’s email claim. What if there’s more than one? What would that mean?&lt;/p&gt;  &lt;p&gt;I’m still of the opinion that an application would benefit from having a custom interface that encapsulated all of the identity needs for that application. It might be as simple as this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IUser
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; }
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; }
    &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsInRole(&lt;span class="kwrd"&gt;string&lt;/span&gt; role);
}&lt;/pre&gt;

&lt;p&gt;I threw IsInRole and Name in the mix for convenience; these are also available on the default IPrincipal/IIdentity pair that you get from ASP.NET, WCF, etc. Email is the interesting addition here.&lt;/p&gt;

&lt;p&gt;The question I have for you, readers, has nothing to do with the structure of IUser itself, but rather, how would you suggest *getting* to a concrete implementation of it? Is this the sort of thing you’d want in an Inversion of Control Container, for example? Or would you prefer to hang this off of a custom principal object that you’d hang off of HttpContext.User?&lt;/p&gt;

&lt;p&gt;Seems like using HttpContext.User makes it less unit-testable because then your code depends on HttpContext.&lt;/p&gt;

&lt;p&gt;While we’re at it, does it offend you that I didn’t derive IUser from IPrincipal? If I had done that, it would imply that you could get to an IClaimsIdentity in order to get to extra stuff without changing the IUser interface. But that wasn’t the intent.&lt;/p&gt;

&lt;p&gt;I’d love your feedback! Keep in mind that comments are moderated so it may take a day or so for your comments to appear here (blame the spammers for this annoyance, sorry!)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=76009" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Security/default.aspx">Security</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Identity/default.aspx">Identity</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>My DevWeek slides and demos</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/21/my-devweek-slides-and-demos.aspx</link><pubDate>Sun, 21 Mar 2010 21:20:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:75578</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=75578</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/21/my-devweek-slides-and-demos.aspx#comments</comments><description>&lt;p&gt;Get them &lt;a href="http://www.pluralsight-training.net/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith.ConferenceDemos/2010_2D00_03_2D00_DevWeek.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks to all who joined me - I had a great time in London!&lt;/p&gt;
&lt;p&gt;Be certain to redeem your Pluralsight On-Demand trial subscriptions, guys!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=75578" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Security/default.aspx">Security</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Identity/default.aspx">Identity</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Labs for my Attack/Defence talk today at DevWeek</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/18/labs-for-my-attack-defence-talk-today-at-devweek.aspx</link><pubDate>Thu, 18 Mar 2010 13:53:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:75511</guid><dc:creator>keith-brown</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=75511</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/18/labs-for-my-attack-defence-talk-today-at-devweek.aspx#comments</comments><description>&lt;p&gt;For those who were in my talk today, I mentioned that the SQL injection and XSS demos are actually labs that you can find on the Internet.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s links to them. I built these for Patterns &amp;amp; Practices a few years ago.&lt;/p&gt;
&lt;p&gt;http://channel9.msdn.com/Wiki/SecurityWiki/InputValidationTrainingModules/&lt;/p&gt;
&lt;p&gt;There&amp;#39;s more here than just the two I mentioned - enjoy!&lt;/p&gt;
&lt;p&gt;Keith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=75511" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Security/default.aspx">Security</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Identity/default.aspx">Identity</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Rocky Mountain Tech Trifecta</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/01/rocky-mountain-tech-trifecta.aspx</link><pubDate>Mon, 01 Mar 2010 16:33:00 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:75314</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=75314</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2010/03/01/rocky-mountain-tech-trifecta.aspx#comments</comments><description>&lt;p&gt;Thanks to Julie and David for inviting me to speak this past weekend in Denver. I hope I opened some eyes to the direction the industry is headed with identity and single sign on!&lt;/p&gt;
&lt;p&gt;You can find my slides &lt;a href="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith.ConferenceDemos/2010_2D00_02_2D00_get_2D00_a_2D00_whiff_2D00_of_2D00_wif.pdf"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For those who attended, don&amp;#39;t forget to redeem your trial coupons for &lt;a href="http://www.pluralsight.com/main/olt/default.aspx"&gt;Pluralsight On-Demand!&lt;/a&gt; training. Five days of access to all of our content should give you enough time to take a full course. Tell your friends if you like what you see!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=75314" width="1" height="1"&gt;</description><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Security/default.aspx">Security</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Geek+talk/default.aspx">Geek talk</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/Identity/default.aspx">Identity</category><category domain="http://www.pluralsight-training.net/community/blogs/keith/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Did FxCop tell you to use System.Uri?</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/10/did-fxcop-tell-you-to-use-system-uri.aspx</link><pubDate>Sat, 10 Oct 2009 18:28:42 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:73093</guid><dc:creator>keith-brown</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=73093</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/10/did-fxcop-tell-you-to-use-system-uri.aspx#comments</comments><description>&lt;p&gt;It told me to do that. And &lt;a href="http://www.pluralsight.com/community/blogs/keith/archive/2009/10/10/beware-uri-tostring.aspx" target="_blank"&gt;silly me&lt;/a&gt;, I took the advice.&lt;/p&gt;  &lt;p&gt;Maybe it wasn’t silly advice at all. But when, like me, you’ve been used to programming ASP.NET for years (which does NOT follow this advice) and you flip over to use the Uri class to represent URI instead of raw strings (like ASP.NET still does), you will be in for a few surprises that may hurt you down the road.&lt;/p&gt;  &lt;p&gt;Don’t get me wrong. This is a bit of a rant, and I recommend using System.Uri. But I can recommend using it only after you’re aware of the gotchas.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1) System.Uri is not at all friendly to relative URI.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Many of the most useful properties that help you parse a URI are simply not supported for relative URI. Get used to your code compiling fine and then at runtime seeing InvalidOperationException thrown when you try to access helpful properties such as Uri.Query, etc. Sure seems like it would be helpful to have an HttpUri derived class that *would* know how to work with relative HTTP URI. I would certainly use it!&lt;/p&gt;  &lt;p&gt;My recommendation to avoid surprises here? Test evey line of code that uses System.Uri with relative URI. Now some code will be specifically designed to work only with absolute URI, and in that case, you should use the Uri.IsAbsoluteUri property to confirm your assumption as part of that code.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2) Beware converting System.Uri to its string value.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Use Uri.AbsoluteUri to pull out the string value when you know you’ve got an absolute URI.&lt;/p&gt;  &lt;p&gt;If the Uri could be relative, AbsoluteUri will throw InvalidOperationException (because, well, it’s not an absolute URI). But don’t fall back and call Uri.ToString instead &lt;a href="http://www.pluralsight.com/community/blogs/keith/archive/2009/10/10/beware-uri-tostring.aspx" target="_blank"&gt;like I did&lt;/a&gt;. Prefer Uri.OriginalString which acts more like Uri.AbsoluteUri in that it does not transform the URI before returning it like Uri.ToString does (Uri.ToString unescapes the URI which could leave you with a bug that only shows up occasionally).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3) Take what the debugger shows you about System.Uri with a grain of salt.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The debugger appears to call Uri.ToString to show you the value of a URI. This will confuse the heck out of you when you’re looking at a URI that you KNOW contains escaped characters, because it will appear as if the URI has been unescaped. If you think you’re a victim of this treachery, set your watch on the OriginalString property of your Uri instead and breathe a sigh of relief that you are not crazy after all.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Microsoft should practice what they preach.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If ASP.NET used the URI class like FxCop tells us we should, it’d be much harder to run into problems with (2) because developers wouldn’t be worried about converting back and forth between System.Uri and strings. Indeed when you program ASP.NET it’s actually harder to write correct code using System.Uri because of these required conversions. You certainly do need to think a lot harder when using System.Uri. I think the ASP.NET team should talk with the FxCop team and get their story straight. Either use URI everywhere, or strings everywhere. Expecting imperfect developers (like me) to deal with this boundary is just asking for trouble, IMHO.&lt;/p&gt;  &lt;p&gt;Thanks for listening to my little rant. I hope this spares somebody else the headaches I’ve endured trying to use System.Uri in my ASP.NET web apps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=73093" width="1" height="1"&gt;</description></item><item><title>Beware Uri.ToString</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/10/beware-uri-tostring.aspx</link><pubDate>Sat, 10 Oct 2009 18:04:20 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:73092</guid><dc:creator>keith-brown</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=73092</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/10/beware-uri-tostring.aspx#comments</comments><description>&lt;p&gt;I admit it. System.Uri (from the .NET Framework) has had me fooled for a long time. Normally when I need to extract the string value of a Uri instance, I use the AbsoluteUri method to do that. But that doesn’t work when the Uri instance models a relative URI. Indeed support for relative URI in the Uri class is almost nonexistant (makes me wish for a derived class called HttpUri that *would* allow you to work with relative URI, but that’s a topic for another day).&lt;/p&gt;  &lt;p&gt;So the quick and dirty fallback I took when I wasn’t sure what type of Uri I had was to call ToString() to get the value of the URI (typically to pass to Response.Redirect, which sadly doesn’t use the Uri class, but expects a string). And this works just dandy until you get a Uri that has escaped characters in it that need to stay escaped for things to work properly (the example that killed me was ReturnUrl for Forms auth in ASP.NET).&lt;/p&gt;  &lt;p&gt;The problem with carelessly using Uri.ToString is that it unescapes the URI before returning it.&lt;/p&gt;  &lt;p&gt;That bears repeating, in bold.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Uri.ToString unescapes the URI before returning it.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The documentation for this method clearly states that this happens. But if you’re not thinking about escaped characters when you write your code, you’re not going to notice that anything’s wrong until it actually encounters certain escape sequences (in my case, the ReturnUrl was being truncated after an escaped ampersand got unescaped by Uri.ToString).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;This can be really confusing while debugging…&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;…when for example, you hover your mouse over a variable of type System.Uri in the debugger. Because the debugger calls ToString() to get a string to display (at least I assume this is what’s happening, because if you set a watch on a System.Uri object, what you see will be different than if you watched its OriginalString or AbsoluteUri property instead, if there are escaped chars in the URI). This fooled me for a long time. But no longer! Now I know to take what the debugger shows for a Uri object with a grain of salt.&lt;/p&gt;  &lt;p&gt;Unless you *really* want to unescape the URI, when writing code that uses the System.Uri class, I’d recommend using Uri.OriginalString instead of ToString to get the value of a Uri that may be absolute or relative. That will *not* unescape the string, and it’s one of the few properties on the Uri class that don’t throw an InvalidOperationException for a relative URI.&lt;/p&gt;  &lt;p&gt;Here are my new personal rules that I’m going to use when using the System.Uri class:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Use Uri.AbsoluteUri to get the value of a URI when you know it’s absolute.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Use Uri.OriginalString to get the value of a URI when it could be either absolute or relative.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Use Uri.ToString to get the value of a URI only when you really want it to be unescaped (e.g. when you want to display it nicely for a human).&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I hope this saves you a headache like the one I’ve had trying to track down the silly bug that this caused in our website.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=73092" width="1" height="1"&gt;</description></item><item><title>What goes into claims</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/07/what-goes-into-claims.aspx</link><pubDate>Wed, 07 Oct 2009 18:52:45 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:73056</guid><dc:creator>keith-brown</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=73056</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/07/what-goes-into-claims.aspx#comments</comments><description>&lt;p&gt;I love the pictures that &lt;a href="http://blogs.msdn.com/vbertocci/default.aspx" target="_blank"&gt;Vittorio&lt;/a&gt; uses in &lt;a href="http://blogs.msdn.com/vbertocci/archive/2009/05/05/what-goes-into-claims.aspx" target="_blank"&gt;this post&lt;/a&gt;. While I’ve always thought of issuers as “caring” for their users (in the case where the issuer is acting as an identity provider) or “caring” for their apps (in the case where the issuer is designed to issue tokens with claims specific to an app), Vittorio takes it a step further and shows the boundaries at which the user’s token can be “enriched” by authorities as these boundaries are crossed. I think this is an excellent way to think about things.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Now that there’s actually something to toy with, as opposed to hand-weave how beautiful a claims-flavoured world would be, I distinctly felt a change in the kind of questions I get: more pragmatic, aimed at understanding how to solve specific *practical* (as opposed to hypothetical) problems or how to integrate with existing assets. One thing that really surprised me is how difficult it could be for people to understand what to put in claims, or who is supposed to add what/where, and so on. There is surprisingly little in literature about this: or rather, this should not surprise at all since the tools that would enable the industry to even pose the question are emerging just now. &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;So, after so many practical/basic posts lately here there’s some scatter consideration about what should go into claims…&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;We’re still a ways from being able to prescribe detailed guidance for what to put into claims, where to put it, etc. but this is a step in the right direction. Thanks, Vittorio.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=73056" width="1" height="1"&gt;</description></item><item><title>Using LET in LINQ with extension method syntax</title><link>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/07/using-let-in-linq-with-extension-method-syntax.aspx</link><pubDate>Wed, 07 Oct 2009 17:53:03 GMT</pubDate><guid isPermaLink="false">d057c89c-07b5-4bfb-b52f-d79d1e3ece89:73053</guid><dc:creator>keith-brown</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.pluralsight-training.net/community/blogs/keith/rsscomments.aspx?PostID=73053</wfw:commentRss><comments>http://www.pluralsight-training.net/community/blogs/keith/archive/2009/10/07/using-let-in-linq-with-extension-method-syntax.aspx#comments</comments><description>&lt;p&gt;For a variety of reasons (many of which &lt;a href="http://www.pluralsight.com/main/instructor.aspx?name=scott-allen" target="_blank"&gt;Scott Allen&lt;/a&gt; discusses in his &lt;a href="http://www.pluralsight.com/main/olt/Course.aspx?n=linq-fundamentals" target="_blank"&gt;wonderful LINQ course&lt;/a&gt;), I prefer to use extension method syntax with LINQ instead of query expression syntax. But one thing I miss is the “let” operation that allows me to compute intermediate results and store them in a new variable.&lt;/p&gt;  &lt;p&gt;This morning I came across a case where this would really simplify things, so I sat down to remember how to do it (I know I’ve done it before but I couldn’t remember the trick). So I wrote the simplest query I could think of using LET…&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt;[] input = { &lt;span class="str"&gt;&amp;quot;asdf&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;asd&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;as&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;a&amp;quot;&lt;/span&gt; };

IEnumerable&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; results =
    from s &lt;span class="kwrd"&gt;in&lt;/span&gt; input
    let x = s.Length
    select &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;{0} ({1})&amp;quot;&lt;/span&gt;, s, x);

Print(results);&lt;/pre&gt;

&lt;p&gt;…and looked at it with &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;RedGate Reflector&lt;/a&gt;, and remembered how I’d done this before – by introducing an enveloping anonymous type. Here’s the equivalent using extension methods:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;results = input
    .Select(s =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; { s = s, x = s.Length })
    .Select(e =&amp;gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;{0} ({1})&amp;quot;&lt;/span&gt;, e.s, e.x));&lt;/pre&gt;

&lt;p&gt;Both of these queries produce the same results:&lt;/p&gt;

&lt;p&gt;asdf (4)
  &lt;br /&gt;asd (3)

  &lt;br /&gt;as (2)

  &lt;br /&gt;a (1)&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;There’s an object being processed in the pipeline – in this case it’s a string. The trick is to envelope that object with an anonymous type so that you can add one or more sibling variables that travel with it through the pipeline. The variable “e” in this example is the envelope.&lt;/p&gt;

&lt;p&gt;It’s not often I need LET, but when I do, I’ll be glad I jotted this down.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.pluralsight-training.net/community/aggbug.aspx?PostID=73053" width="1" height="1"&gt;</description></item></channel></rss>