<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/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>Tales from the Evil Empire : ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx</link><description>Tags: ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Testing Orchard drivers</title><link>http://weblogs.asp.net/bleroy/archive/2013/04/15/testing-orchard-drivers.aspx</link><pubDate>Mon, 15 Apr 2013 19:51:31 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10162458</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=10162458</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/04/15/testing-orchard-drivers.aspx#comments</comments><description>&lt;p&gt;If you’ve ever tried to test Orchard part drivers, you may have been blocked by the fact that the methods on drivers are protected. That, fortunately, doesn’t mean they are untestable. Those methods are still accessible through explicit interface implementations. In particular, drivers implement IContentPartDriver, which is defined as follows.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public interface IContentPartDriver : IDependency {
    DriverResult BuildDisplay(BuildDisplayContext context);
    DriverResult BuildEditor(BuildEditorContext context);
    DriverResult UpdateEditor(UpdateEditorContext context);
    void Importing(ImportContentContext context);
    void Imported(ImportContentContext context);
    void Exporting(ExportContentContext context);
    void Exported(ExportContentContext context);
    IEnumerable&amp;lt;ContentPartInfo&amp;gt; GetPartInfo();
    void GetContentItemMetadata(GetContentItemMetadataContext context);
}&lt;/pre&gt;

&lt;p&gt;By casting your driver to this interface, you get public access to these methods.&lt;/p&gt;

&lt;p&gt;For example, here is some code I wrote recently to test the import and export methods of a driver:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[Test]
public void ImportGetAllDefinedProperties() {
    var doc = XElement.Parse(@&amp;quot;
&amp;lt;data&amp;gt;
&amp;lt;UspsShippingMethodPart
    Name=&amp;quot;&amp;quot;Foo&amp;quot;&amp;quot;
    Size=&amp;quot;&amp;quot;L&amp;quot;&amp;quot;
    WidthInInches=&amp;quot;&amp;quot;10&amp;quot;&amp;quot;
    LengthInInches=&amp;quot;&amp;quot;11&amp;quot;&amp;quot;
    HeightInInches=&amp;quot;&amp;quot;12&amp;quot;&amp;quot;
    MaximumWeightInOunces=&amp;quot;&amp;quot;1.3&amp;quot;&amp;quot;
    Priority=&amp;quot;&amp;quot;14&amp;quot;&amp;quot;
    International=&amp;quot;&amp;quot;true&amp;quot;&amp;quot;
    RegisteredMail=&amp;quot;&amp;quot;true&amp;quot;&amp;quot;
    Insurance=&amp;quot;&amp;quot;false&amp;quot;&amp;quot;
    ReturnReceipt=&amp;quot;&amp;quot;true&amp;quot;&amp;quot;
    CertificateOfMailing=&amp;quot;&amp;quot;true&amp;quot;&amp;quot;
    ElectronicConfirmation=&amp;quot;&amp;quot;true&amp;quot;&amp;quot;/&amp;gt;
&amp;lt;/data&amp;gt;
&amp;quot;);
    var driver = new UspsShippingMethodPartDriver(null)
        as IContentPartDriver;
    var part = new UspsShippingMethodPart();
    Helpers.PreparePart&amp;lt;UspsShippingMethodPart, UspsShippingMethodPartRecord&amp;gt;(
        part, &amp;quot;UspsShippingMethod&amp;quot;);
    var context = new ImportContentContext(
        part.ContentItem, doc, new ImportContentSession(null));
    driver.Importing(context);

    Assert.That(part.Name, Is.EqualTo(&amp;quot;Foo&amp;quot;));
    Assert.That(part.Size, Is.EqualTo(&amp;quot;L&amp;quot;));
    Assert.That(part.WidthInInches, Is.EqualTo(10));
    Assert.That(part.LengthInInches, Is.EqualTo(11));
    Assert.That(part.HeightInInches, Is.EqualTo(12));
    Assert.That(part.MaximumWeightInOunces, Is.EqualTo(1.3));
    Assert.That(part.Priority, Is.EqualTo(14));
    Assert.That(part.International, Is.True);
    Assert.That(part.RegisteredMail, Is.True);
    Assert.That(part.Insurance, Is.False);
    Assert.That(part.ReturnReceipt, Is.True);
    Assert.That(part.CertificateOfMailing, Is.True);
    Assert.That(part.ElectronicConfirmation, Is.True);
}

[Test]
public void ExportSetsAllAttributes() {
    var driver = new UspsShippingMethodPartDriver(null)
        as IContentPartDriver;
    var part = new UspsShippingMethodPart();
    Helpers.PreparePart&amp;lt;UspsShippingMethodPart, UspsShippingMethodPartRecord&amp;gt;(
        part, &amp;quot;UspsShippingMethod&amp;quot;);
    part.Name = &amp;quot;Foo&amp;quot;;
    part.Size = &amp;quot;L&amp;quot;;
    part.WidthInInches = 10;
    part.LengthInInches = 11;
    part.HeightInInches = 12;
    part.MaximumWeightInOunces = 1.3;
    part.Priority = 14;
    part.International = true;
    part.RegisteredMail = true;
    part.Insurance = false;
    part.ReturnReceipt = true;
    part.CertificateOfMailing = true;
    part.ElectronicConfirmation = true;

    var doc = new XElement(&amp;quot;data&amp;quot;);
    var context = new ExportContentContext(part.ContentItem, doc);
    driver.Exporting(context);
    var el = doc.Element(&amp;quot;UspsShippingMethodPart&amp;quot;);

    Assert.That(el, Is.Not.Null);
    Assert.That(el.Attr(&amp;quot;Name&amp;quot;), Is.EqualTo(&amp;quot;Foo&amp;quot;));
    Assert.That(el.Attr(&amp;quot;Size&amp;quot;), Is.EqualTo(&amp;quot;L&amp;quot;));
    Assert.That(el.Attr(&amp;quot;WidthInInches&amp;quot;), Is.EqualTo(&amp;quot;10&amp;quot;));
    Assert.That(el.Attr(&amp;quot;LengthInInches&amp;quot;), Is.EqualTo(&amp;quot;11&amp;quot;));
    Assert.That(el.Attr(&amp;quot;HeightInInches&amp;quot;), Is.EqualTo(&amp;quot;12&amp;quot;));
    Assert.That(el.Attr(&amp;quot;MaximumWeightInOunces&amp;quot;), Is.EqualTo(&amp;quot;1.3&amp;quot;));
    Assert.That(el.Attr(&amp;quot;Priority&amp;quot;), Is.EqualTo(&amp;quot;14&amp;quot;));
    Assert.That(el.Attr(&amp;quot;International&amp;quot;), Is.EqualTo(&amp;quot;true&amp;quot;));
    Assert.That(el.Attr(&amp;quot;RegisteredMail&amp;quot;), Is.EqualTo(&amp;quot;true&amp;quot;));
    Assert.That(el.Attr(&amp;quot;Insurance&amp;quot;), Is.EqualTo(&amp;quot;false&amp;quot;));
    Assert.That(el.Attr(&amp;quot;ReturnReceipt&amp;quot;), Is.EqualTo(&amp;quot;true&amp;quot;));
    Assert.That(el.Attr(&amp;quot;CertificateOfMailing&amp;quot;), Is.EqualTo(&amp;quot;true&amp;quot;));
    Assert.That(el.Attr(&amp;quot;ElectronicConfirmation&amp;quot;), Is.EqualTo(&amp;quot;true&amp;quot;));
}&lt;/pre&gt;

&lt;p&gt;The Attr method, in case you're wondering, is &lt;a href="http://weblogs.asp.net/bleroy/archive/2013/04/14/a-c-helper-to-read-and-write-xml-from-and-to-objects.aspx"&gt;an extension method I blogged about yesterday&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Helper class that I’m using here massages a fake part to behave like a real part. It gives the part a fake record, and adds a fake content item around it. It might not be enough in all situations, but it does make the fake convincing enough in this case.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public static ContentItem PreparePart&amp;lt;TPart, TRecord&amp;gt;(
    TPart part, string contentType, int id = -1)
    where TPart: ContentPart&amp;lt;TRecord&amp;gt;
    where TRecord: ContentPartRecord, new() {

    part.Record = new TRecord();
    var contentItem = part.ContentItem = new ContentItem
    {
        VersionRecord = new ContentItemVersionRecord
        {
            ContentItemRecord = new ContentItemRecord()
        },
        ContentType = contentType
    };
    contentItem.Record.Id = id;
    contentItem.Weld(part);
    return contentItem;
}&lt;/pre&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10162458" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Logging SQL queries in Orchard</title><link>http://weblogs.asp.net/bleroy/archive/2013/04/03/logging-sql-queries-in-orchard.aspx</link><pubDate>Thu, 04 Apr 2013 02:02:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10091735</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=10091735</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/04/03/logging-sql-queries-in-orchard.aspx#comments</comments><description>&lt;p&gt;It is often useful to see what database queries were made during a specific request in Orchard. There are quite a few ways to do this (you can &lt;a href="http://msdn.microsoft.com/en-us/library/ms191006(v=sql.105).aspx"&gt;trace right from SQL Server&lt;/a&gt;, or you can use &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Four2n.MiniProfiler"&gt;Mini-Profiler&lt;/a&gt; for instance), but this morning &lt;a href="http://sebastienros.com/"&gt;Sébastien&lt;/a&gt; showed me a really easy one that I thought I’d share.&lt;/p&gt;  &lt;p&gt;Find the log4net.config file in /src/Orchard.Web/Config and edit it to add the following tag:   &lt;pre class="brush: xml;"&gt;&amp;lt;logger name=&amp;quot;NHibernate.SQL&amp;quot;&amp;gt;
  &amp;lt;priority value=&amp;quot;DEBUG&amp;quot; /&amp;gt;
&amp;lt;/logger&amp;gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Restart the application, then hit the URL you want to test, and look at your logs in App_data/logs. You should see new entries looking like this:
  &lt;pre class="brush: plain;"&gt;2013-04-03 18:57:30,367 [17] NHibernate.SQL -
  SELECT warmupsett0_.Id as Id575_0_,
         warmupsett0_.Urls as Urls575_0_,
         warmupsett0_.Scheduled as Scheduled575_0_,
         warmupsett0_.Delay as Delay575_0_,
         warmupsett0_.OnPublish as OnPublish575_0_
  FROM VuLu_Orchard_Warmup_WarmupSettingsPartRecord warmupsett0_
  WHERE warmupsett0_.Id=@p0;

  @p0 = 1 [Type: Int32 (0)]&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;(only not as nicely formatted)&lt;/p&gt;

&lt;p&gt;To disable the SQL trace, just edit log4net.config and set the value to ERROR instead of DEBUG.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10091735" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/NHibernate/default.aspx">NHibernate</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>This is how we should read hexadecimal…</title><link>http://weblogs.asp.net/bleroy/archive/2013/03/21/this-is-how-we-should-read-hexadecimal.aspx</link><pubDate>Fri, 22 Mar 2013 05:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10030075</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=10030075</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/03/21/this-is-how-we-should-read-hexadecimal.aspx#comments</comments><description>&lt;p&gt;Today my five-year-old told me that when she was four, she thought that what came after ninety-nine was… tenty. You know, because seventy, eighty, ninety, tenty.&lt;/p&gt;  &lt;p&gt;At first I thought it was just funny and charming, but then I realized it was actually a really good idea. Tenty is only nonsensical if you’re counting in base ten (or lower), but it makes total sense for higher bases.&lt;/p&gt;  &lt;p&gt;How do people usually read 0xA0? “A-zero”? How unimaginative! Let’s read that “tenty” from now on!&lt;/p&gt;  &lt;p&gt;Here are some more examples of how to read hexadecimal in a non-boring way:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;0xB3 is eleventy-three&lt;/li&gt;    &lt;li&gt;0xCA is twelvety-ten&lt;/li&gt;    &lt;li&gt;0xD9 is thirteenty-nine&lt;/li&gt;    &lt;li&gt;0xEC is fourteenty-twelve&lt;/li&gt;    &lt;li&gt;0xFF is fifteenty-fifteen&lt;/li&gt;    &lt;li&gt;0xF04A is fifteen hexathousand forty-ten&lt;/li&gt;    &lt;li&gt;0x4B2AC0AA is forty-eleven hexamillion, two hexahundred tenty-twelve hexathousand tenty-ten&lt;/li&gt;    &lt;li&gt;and of course, seven-eleven will have to change their logo to 0x7B.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Is this the greatest thing or what?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10030075" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Geek/default.aspx">Geek</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Math/default.aspx">Math</category></item><item><title>Taking an Orchard site offline while you update it</title><link>http://weblogs.asp.net/bleroy/archive/2013/03/12/taking-an-orchard-site-offline-while-you-update-it.aspx</link><pubDate>Tue, 12 Mar 2013 18:52:28 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9979633</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9979633</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/03/12/taking-an-orchard-site-offline-while-you-update-it.aspx#comments</comments><description>&lt;p&gt;&lt;img title="(c) Bertrand Le Roy 2012" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: left; padding-top: 0px; padding-left: 0px; margin: 2px 10px 5px 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="(c) Bertrand Le Roy 2012" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_181E3DF7.png" width="164" height="244" /&gt;If your hosted environment does not give you a staging site and the means to swap it easily with the production environment like Azure Cloud Services do, or if you don’t have a staging database, or if you just need to take your site offline for the public while you perform data updates in the admin, you may be wondering what solutions you have, if any.&lt;/p&gt;  &lt;p&gt;IIS has an &lt;font face="Courier New"&gt;app_offline.htm&lt;/font&gt; feature that you can use, that will serve a static page for all requests but that’s rather brutal as it does not just take the site offline for your users, it also does so for you. While that file exists, you can do absolutely nothing with your site. You cannot access the admin, you cannot preview your changes, nothing. So when you flip the switch back, it’s anyone’s guess whether the changes you blindly made actually work, even if they did on your machine…&lt;/p&gt;  &lt;p&gt;We need a better solution. Well, I happen to have one...&lt;/p&gt;  &lt;p&gt;All you have to do is create a new theme named “Offline” with just one /Views/Layout.cshtml file containing a message along the lines of “We are updating the site. We apologize for the inconvenience. Please come back in a few minutes.” You can add stylesheets to make it pretty if you want to. It’s a full theme, you can go crazy.&lt;/p&gt;  &lt;p&gt;The important thing is that this theme has one layout, and that this layout does nothing but display its message. It has no zones, so no dynamic content is going to be served to the public from the site no matter what URL is hit.&lt;/p&gt;  &lt;p&gt;Once you have made this theme current, all your visitors are seeing it, but you can still access the admin of the site and do whatever you want.&lt;/p&gt;  &lt;p&gt;Better, you can use the “Theme Preview” feature of Orchard to check what your changes look like while your users continue to see the “offline” page. Just go to Themes, and click Preview on your regular theme…&lt;/p&gt;  &lt;p&gt;Once you are satisfied with your changes and judge the site to be ready to be taken back online, just restore your theme as the current. The “Offline” theme can sit there and do nothing until the next time you need it.&lt;/p&gt;  &lt;p&gt;I’ve used this technique successfully last time I updated an Orchard site. It worked great. I hope it helps others…&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9979633" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Dead simple stubbing for JavaScript</title><link>http://weblogs.asp.net/bleroy/archive/2013/03/08/dead-simple-stubbing-for-javascript.aspx</link><pubDate>Fri, 08 Mar 2013 18:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9961668</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9961668</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/03/08/dead-simple-stubbing-for-javascript.aspx#comments</comments><description>&lt;p&gt;I’m writing a lot of JavaScript these days, and for testing I mostly use QUnit. When I need to quickly stub a piece of the code that I’m testing, I like to use the following micro-library. What it does is enable you to replace a bunch of methods on an object with stub versions, in a easily reversible way.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I use RequireJS, but if you don’t, just remove the define and outer function.&lt;/p&gt; &lt;/blockquote&gt;  &lt;pre class="brush: js;"&gt;define(function() {
    var stub = function(obj, stubs) {
        obj._stubbed = obj._stubbed || {};
        for (var name in stubs) {
            obj._stubbed[name] = obj[name];
            obj[name] = stubs[name];
        }
    };
    stub.restore = function(obj) {
        if (!obj || !obj._stubbed) return;
        for (var name in obj._stubbed) {
            obj[name] = obj._stubbed[name];
        }
        delete obj._stubbed;
    };
    return stub;
});&lt;/pre&gt;

&lt;p&gt;Here is how you would replace two methods bar and baz on an object foo:&lt;/p&gt;

&lt;pre class="brush: js;"&gt;stub(foo, {
    bar: function() {
        return &amp;quot;stubbed bar&amp;quot;;
    },
    baz: function(glop) {
        return &amp;quot;stubbed baz &amp;quot; + glop;
    }
});&lt;/pre&gt;

&lt;p&gt;And here is how you can put everything back in place once you’re done:&lt;/p&gt;

&lt;pre class="brush: js;"&gt;stub.restore(foo);&lt;/pre&gt;

&lt;p&gt;I hope this helps...&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9961668" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Always have a host or URL prefix on the default Orchard tenant</title><link>http://weblogs.asp.net/bleroy/archive/2013/02/24/always-have-a-host-or-url-prefix-on-the-default-orchard-tenant.aspx</link><pubDate>Mon, 25 Feb 2013 01:54:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9909716</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9909716</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/02/24/always-have-a-host-or-url-prefix-on-the-default-orchard-tenant.aspx#comments</comments><description>&lt;p&gt;The multi-tenancy feature in Orchard enables you to host multiple sites within the same Orchard instance. It’s not a a security feature, just a way to improve site density, and to enable you to save on hosting costs. Nevertheless, a request to a specific existing tenant should never be answered with a page from another tenant. Ever.&lt;/p&gt;  &lt;p&gt;There is however a fallback mechanism that enables one tenant to handle all requests that weren’t identified by another tenant. While this could be considered useful in some scenarios, I’m hereby declaring it bad practice.&lt;/p&gt;  &lt;p&gt;If for any reason a tenant fails to start, for example, requests to that tenant are going to fall back. Even if you were in a scenario where you considered fallback to be useful, this is an unexpected and positively undesirable result. It’s much better to fail with an error message or a 404 than to fail with a fallback to a different site than the one the client asked for.&lt;/p&gt;  &lt;p&gt;So here is my recommendation:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font style="style"&gt;&lt;strong&gt;Always have a host or URL prefix configured on &lt;em&gt;all&lt;/em&gt; tenants, in particular the default tenant.&lt;/strong&gt;&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;This way, no fallback will ever happen, and requests will only be handled by a tenant that recognizes its own host name.&lt;/p&gt; &lt;p&gt;Here is, for example, the new configuration of the default tenant on my hosted web sites:&lt;/p&gt;  &lt;p&gt;&lt;img title="Always specify the host name on your Orchard tenants" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 8px 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Always specify the host name on your Orchard tenants" src="http://weblogs.asp.net/blogs/bleroy/DefaultTenantConfig_35234678.png" width="522" height="192" /&gt;&lt;/p&gt;  &lt;p&gt;Note that I have multiple hosts configured here, including the host that I use on my dev machine for local development, but the point here is to specify something on all tenants.&lt;/p&gt;  &lt;p&gt;This is important.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9909716" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Easy content templates for Orchard, take 2</title><link>http://weblogs.asp.net/bleroy/archive/2013/02/13/easy-content-templates-for-orchard-take-2.aspx</link><pubDate>Thu, 14 Feb 2013 00:21:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9869783</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9869783</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/02/13/easy-content-templates-for-orchard-take-2.aspx#comments</comments><description>&lt;p&gt;Placement.info is an XML file that orchestrates the different parts of a content item and sends each of the shapes they create into specific local content zones. If the previous sentence sounded confusing to you, fear not, this post is for you.&lt;/p&gt;  &lt;p&gt;When writing an Orchard theme, more often than not, you know exactly what parts exist in your content type, and you know where you want them to render. Placement can be extremely powerful, but it’s rather abstract and it reverses the usual logic of placing contents on a page. What most people really want to do is write a template with simple markup and placeholders inside that markup for the rendering of specific parts such as title, summary, tags, etc. Placement forces you to dispatch those part shapes from a completely separate file.&lt;/p&gt;  &lt;p&gt;In the Summer of 2011, I wrote a little article to explain how to write custom templates for specific content types in Orchard, without using &lt;a href="http://orchardproject.net/docs/Understanding-placement-info.ashx"&gt;placement.info&lt;/a&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2011/07/31/so-you-don-t-want-to-use-placement-info.aspx"&gt;So you don’t want to use placement.info?&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The solution worked, but relied on a hack that will break with the next version of Orchard (1.7).&lt;/p&gt;  &lt;p&gt;Sébastien Ros gave me a little trick the other day that enables the same thing, in a simpler, less hacky form. It still uses placement somewhat, but in a very simple way.&lt;/p&gt;  &lt;p&gt;The idea is to create one local zone per part instead of the usual header, content and footer zones. Here we are going to send the relevant shapes to those zones through placement:   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Match&lt;/span&gt; &lt;span class="attr"&gt;ContentType&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;BlogPost&amp;quot;&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;Match&lt;/span&gt; &lt;span class="attr"&gt;DisplayType&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Summary&amp;quot;&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;Place&lt;/span&gt; &lt;span class="attr"&gt;Parts_Common_Body_Summary&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Summary:0&amp;quot;&lt;/span&gt;
           &lt;span class="attr"&gt;Parts_Tags_ShowTags&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Tags:0&amp;quot;&lt;/span&gt;
           &lt;span class="attr"&gt;Parts_Common_Metadata_Summary&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MetadataSummary:0&amp;quot;&lt;/span&gt;
           &lt;span class="attr"&gt;Parts_Comments_Count&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CommentsCount:0&amp;quot;&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;Match&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;Match&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;This sends shapes into Summary, Tags, MetadataSummary and CommentsCount zones. Those do not yet exist. &lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Caveat:&lt;/strong&gt; when naming your custom zones, be careful not to collide with existing properties or zones on the Model, lest you end up with unexpected and confusing results. Using longish and very explicit names usually works well for that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The template can now simply create and render those zones. Here is my Content-BlogPost.Summary.cshtml template:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;@using Orchard.ContentManagement
@{
    var blogPost = Model.ContentItem;
}
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;article&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;content-item blog-post&amp;quot;&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;header&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;h1&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;@Url.ItemDisplayUrl((IContent)blogPost)&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;br /&gt;      &lt;/span&gt;@blogPost.TitlePart.Title&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h1&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;header&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    @Display(Model.Summary)
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;footer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    @Display(Model.Tags)
    @Display(Model.MetadataSummary)
    @Display(Model.CommentsCount)
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;footer&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;article&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Notice how in the case of the title, I’m not even using the shape given by the part, but I’m accessing the properties directly on the TitlePart. The other parts are rendered through the special zone that we created using the Display function. And that is all. You can now focus on building your template, and it will be pretty obvious what will render where…&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9869783" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Creating simple custom Orchard widgets</title><link>http://weblogs.asp.net/bleroy/archive/2013/02/05/creating-simple-custom-orchard-widgets.aspx</link><pubDate>Wed, 06 Feb 2013 06:21:27 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9844342</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9844342</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2013/02/05/creating-simple-custom-orchard-widgets.aspx#comments</comments><description>&lt;p&gt;If you want to create a simple widget in Orchard, such as a box of social links, you have three possibilities:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Find &lt;a href="http://gallery.orchardproject.net/List/Modules/Orchard.Module.Szmyd.Orchard.Modules.Sharing"&gt;a module on the gallery&lt;/a&gt; or write one yourself, but there is overhead associated with modules, which may make this overkill.&lt;/li&gt;    &lt;li&gt;Use an HTML widget and paste a bunch of HTML and Javascript, hoping administrators of the site don’t break it accidentally. I don’t like this, it feels like a hack.&lt;/li&gt;    &lt;li&gt;Create a simple widget, following the instructions in this post.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;First, let’s create a content type (in the admin, go to Content / Content Types and click “Create new type”) and call it “Social Links”.&lt;/p&gt;  &lt;p&gt;Add the widget and identity parts. Those are the only ones you really need:&lt;/p&gt;  &lt;p&gt;&lt;img title="Pick the identity and widget parts" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="Pick the identity and widget parts" src="http://weblogs.asp.net/blogs/bleroy/image_678C700B.png" width="106" height="302" /&gt;&lt;/p&gt;  &lt;p&gt;Uncheck creatable and draftable, add the “Widget” stereotype (with an upper-case ‘W’: I made the mistake, as you can see, of using a lower-case ‘w’ on my first try, and it did prevent the widget from being seen as such):&lt;/p&gt;  &lt;p&gt;&lt;img title="configuring the new type" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="configuring the new type" src="http://weblogs.asp.net/blogs/bleroy/image_04951ED4.png" width="272" height="302" /&gt;&lt;/p&gt;  &lt;p&gt;Now when you add a widget, the social links widget appears in the list:&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="The new widget can now be added to a zone" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="The new widget can now be added to a zone" src="http://weblogs.asp.net/blogs/bleroy/image_4FF75349.png" width="144" height="302" /&gt;&lt;/p&gt;  &lt;p&gt;It’s a simple, apparently featureless widget, which minimizes the chances of accidentally messing it up.&lt;/p&gt;  &lt;p&gt;All that’s left to do now is to add a template to the theme that will render what we want. We’ll take advantage of shape alternates. Using shape tracing, we quickly discover that we can name our template Widget-SocialLinks.cshtml to target it narrowly enough:&lt;/p&gt;  &lt;p&gt;&lt;img title="Shape tracing can show us how to override the rendering" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="Shape tracing can show us how to override the rendering" src="http://weblogs.asp.net/blogs/bleroy/image_6AC37955.png" width="402" height="220" /&gt;&lt;/p&gt;  &lt;p&gt;Once the file has been added to the Views folder of my theme, I can paste in &lt;a href="https://developers.facebook.com/docs/reference/plugins/like/"&gt;the code from Facebook&lt;/a&gt;, Twitter, or whatever else I want in there.&lt;/p&gt;  &lt;p&gt;&lt;img title="All done" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="All done" src="http://weblogs.asp.net/blogs/bleroy/image_7EDF268F.png" width="269" height="122" /&gt;&lt;/p&gt;  &lt;p&gt;Done. Fastest and simplest way to create a new widget.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9844342" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Writing an unthemed view while still using Orchard shapes and helpers</title><link>http://weblogs.asp.net/bleroy/archive/2012/10/20/writing-an-unthemed-view-while-still-using-orchard-shapes-and-helpers.aspx</link><pubDate>Sat, 20 Oct 2012 21:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9160341</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9160341</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/10/20/writing-an-unthemed-view-while-still-using-orchard-shapes-and-helpers.aspx#comments</comments><description>&lt;p&gt;This quick tip will show how you can write a custom view for a custom controller action in Orchard that does not use the current theme, but that still retains the ability to use shapes, as well as zones, Script and Style helpers.&lt;/p&gt;  &lt;p&gt;The controller action, first, needs to opt out of theming:   &lt;pre class="csharpcode"&gt;[Themed(&lt;span class="kwrd"&gt;false&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index() {}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Then, we still want to use a shape as the view model, because Clay is so awesome:
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; dynamic _shapeFactory;

&lt;span class="kwrd"&gt;public&lt;/span&gt; MyController(IShapeFactory shapeFactory) {
    _shapeFactory = shapeFactory;
}

[Themed(&lt;span class="kwrd"&gt;false&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index() {
    &lt;span class="kwrd"&gt;return&lt;/span&gt; View(_shapeFactory.MyShapeName(
        Foo: 42,
        Bar: &lt;span class="str"&gt;&amp;quot;baz&amp;quot;&lt;/span&gt;
        ));
}&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;As you can see, we injected a shape factory, and that enables us to build our shape from our action and inject that into the view as the model.&lt;/p&gt;

&lt;p&gt;Finally, in the view (that would in Views/MyController/Index.cshtml here), just use helpers as usual. The only gotcha is that you need to use “Layout” in order to declare zones, and that two of those zones, Head and Tail, are mandatory for the top and bottom scripts and stylesheets to be injected properly. Names are important here.
  &lt;pre class="csharpcode"&gt;@{
    Style.Include(&amp;quot;somestylesheet.css&amp;quot;);
    Script.Require(&amp;quot;jQuery&amp;quot;);
    Script.Include(&amp;quot;somescript.js&amp;quot;);
    using(Script.Foot()) {
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            $(&lt;span class="kwrd"&gt;function&lt;/span&gt; () {
                &lt;span class="rem"&gt;// Do stuff&lt;/span&gt;
            })
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&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;DOCTYPE&lt;/span&gt; &lt;span class="attr"&gt;html&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;html&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;head&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;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;My unthemed page&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        @Display(Layout.Head)
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;head&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;body&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;h1&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;My unthemed page&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;h1&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;@Model.Foo is the answer.&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;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    @Display(Layout.Tail)
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Note that if you define your own zones using &lt;font face="Courier New"&gt;@Display(Layout.SomeZone)&lt;/font&gt; in your view, you can perfectly well send additional shapes to them from your controller action, if you injected an instance of IWorkContextAccessor:

  &lt;pre class="csharpcode"&gt;_workContextAccessor.GetContext().Layout
    .SomeZone.Add(_shapeFactory.SomeOtherShape());&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Of course, you’ll need to write a SomeOtherShape.cshtml template for that shape but I think this is pretty neat.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9160341" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Clay/default.aspx">Clay</category></item><item><title>TypeScript first impressions</title><link>http://weblogs.asp.net/bleroy/archive/2012/10/01/typescript-first-impressions.aspx</link><pubDate>Mon, 01 Oct 2012 20:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9031444</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=9031444</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/10/01/typescript-first-impressions.aspx#comments</comments><description>&lt;p&gt;Anders published &lt;a href="http://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript"&gt;a video of his new project today&lt;/a&gt;, which aims at creating a superset of JavaScript, that compiles down to regular current JavaScript. Anders is a tremendously clever guy, and it always shows in his work. There is much to like in the enterprise (good code completion, refactoring and adoption of &lt;a href="http://weblogs.asp.net/bleroy/archive/2012/09/03/namespaces-are-obsolete.aspx"&gt;the module pattern instead of namespaces&lt;/a&gt; to name three), but a few things made me rise an eyebrow.&lt;/p&gt;  &lt;p&gt;First, there is no mention of &lt;a href="http://coffeescript.org/"&gt;CoffeeScript&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Google_Dart"&gt;Dart&lt;/a&gt;, but he does talk briefly about &lt;a href="http://www.nikhilk.net/ScriptSharp"&gt;Script#&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Google_Web_Toolkit"&gt;GWT&lt;/a&gt;. This is probably because the target audience seems to be the same as the audience for the latter two, i.e. developers who are more comfortable with statically-typed languages such as C# and Java than dynamic languages such as JavaScript. I don’t think he’s aiming at JavaScript developers. Classes and interfaces, although well executed, are not especially appealing.&lt;/p&gt;  &lt;p&gt;Second, as any code generation tool (and this is true of CoffeeScript as well), you’d better like the generated code. I didn’t, unfortunately. The code that I saw is not the code I would have written. What’s more, I didn’t always find the TypeScript code especially more expressive than what it gets compiled to.&lt;/p&gt;  &lt;p&gt;I also have a few questions.&lt;/p&gt;  &lt;p&gt;Is it possible to duck-type interfaces? For example, if I have an IPoint2D interface with x and y coordinates, can I pass any object that has x and y into a function that expects IPoint2D or do I need to necessarily create a class that implements that interface, and new up an instance that explicitly declares its contract? The appeal of dynamic languages is the ability to make objects as you go. This needs to be kept intact.&lt;/p&gt;&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt;: this works.&lt;/p&gt;  &lt;p&gt;More technical: why are generated variables and functions prefixed with _ rather than the $ that the &lt;a href="http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf"&gt;EcmaScript&lt;/a&gt; spec recommends for machine-generated variables?&lt;/p&gt;  &lt;p&gt;In conclusion, while this is a good contribution to the set of ideas around JavaScript evolution, I don’t expect a lot of adoption outside of the devoted Microsoft developers, but maybe some influence on the language itself. But I’m often wrong. I would certainly not use it because &lt;strong&gt;I disagree with the central motivation&lt;/strong&gt; for doing this: Anders explicitly says he built this because “writing application-scale JavaScript is hard”. I would restate that “writing application-scale JavaScript is hard for people who are used to statically-typed languages”. The community has built a set of good practices over the last few years that do scale quite well, and many people are successfully developing and maintaining impressive applications directly in JavaScript.&lt;/p&gt;  &lt;p&gt;You can play with TypeScript here: &lt;a href="http://www.typescriptlang.org"&gt;http://www.typescriptlang.org&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9031444" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>Namespaces are obsolete</title><link>http://weblogs.asp.net/bleroy/archive/2012/09/03/namespaces-are-obsolete.aspx</link><pubDate>Mon, 03 Sep 2012 21:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8888702</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>59</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8888702</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/09/03/namespaces-are-obsolete.aspx#comments</comments><description>&lt;p&gt;&lt;img title="Microsoft.SqlServer.Management.Smo.Agent" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: left; padding-top: 0px; padding-left: 0px; margin: 0px 10px 10px 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Microsoft.SqlServer.Management.Smo.Agent" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_64CD2233.png" width="244" height="232" /&gt;To those of us who have been around for a while, namespaces have been part of the landscape. One could even say that they have been defining the large-scale features of the landscape in question.&lt;/p&gt;  &lt;p&gt;However, something happened fairly recently that I think makes this venerable structure obsolete. Before I explain this development and why it’s a superior concept to namespaces, let me recapitulate what namespaces are and why they’ve been so good to us over the years…&lt;/p&gt;  &lt;p&gt;Namespaces are used for a few different things:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Scope&lt;/strong&gt;: a namespace delimits the portion of code where a name (for a class, sub-namespace, etc.) has the specified meaning. Namespaces are usually the highest-level scoping structures in a software package.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Collision prevention&lt;/strong&gt;: name collisions are a universal problem. Some systems, such as jQuery, wave it away, but the problem remains. Namespaces provide a reasonable approach to global uniqueness (and in some implementations such as XML, enforce it). In .NET, there are &lt;a href="http://msdn.microsoft.com/en-us/library/c3ay4x3d(VS.80).aspx"&gt;ways to relocate a namespace&lt;/a&gt; to avoid those rare collision cases.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Hierarchy&lt;/strong&gt;: programmers like neat little boxes, and especially boxes within boxes within boxes. For some reason. Regular human beings on the other hand, tend to think linearly, which is why the Windows explorer for example has tried in a few different ways to flatten the file system hierarchy for the user.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;1 is clearly useful because we need to protect our code from bleeding effects from the rest of the application (and vice versa). A language with only global constructs may be what some of us started programming on, but it’s not desirable in any way today.&lt;/p&gt;  &lt;p&gt;2 may not be always reasonably worth the trouble (jQuery is doing fine with its global plug-in namespace), but we still need it in many cases. One should note however that globally unique names are not the only possible implementation. In fact, they are a rather extreme solution. What we really care about is collision prevention &lt;em&gt;within our application&lt;/em&gt;. What happens outside is irrelevant.&lt;/p&gt;  &lt;p&gt;3 is, more than anything, an aesthetical choice. A common convention has been to encode the whole pedigree of the code into the namespace. Come to think about it, we never think we need to import “Microsoft.SqlServer.Management.Smo.Agent” and that would be very hard to remember. What we want to do is bring nHibernate into our app.&lt;/p&gt;  &lt;p&gt;And this is precisely what you’ll do with modern package managers and module loaders. I want to take the specific example of &lt;a href="http://requirejs.org"&gt;RequireJS&lt;/a&gt;, which is commonly used with &lt;a href="http://nodejs.org/"&gt;Node&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Here is how you import a module with RequireJS:   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; http = require(&lt;span class="str"&gt;&amp;quot;http&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;This is of course importing a HTTP stack module into the code. There is no noise here. Let’s break this down.&lt;/p&gt;

&lt;p&gt;Scope (1) is provided by the one scoping mechanism in JavaScript: the closure surrounding the module’s code. Whatever scoping mechanism is provided by the language would be fine here.&lt;/p&gt;

&lt;p&gt;Collision prevention (2) is very elegantly handled. Whereas relocating is an afterthought, and an exceptional measure with namespaces, it is here on the frontline. You &lt;em&gt;always&lt;/em&gt; relocate, using an extremely familiar pattern: variable assignment. We are very much used to managing our local variable names and any possible collision will get solved very easily by picking a different name.&lt;/p&gt;

&lt;p&gt;Wait a minute, I hear some of you say. This is only taking care of collisions on the client-side, on the left of that assignment. What if I have two libraries with the name “http”? Well, You can better qualify the path to the module, which is what the require parameter really is.&lt;/p&gt;

&lt;p&gt;As for hierarchical organization, you don’t really want that, do you?&lt;/p&gt;

&lt;p&gt;RequireJS’ module pattern does elegantly cover the bases that namespaces used to cover, but it also promotes additional good practices.&lt;/p&gt;

&lt;p&gt;First, it promotes usage of self-contained, single responsibility units of code through the closure-based, stricter scoping mechanism. Namespaces are somewhat more porous, as using/import statements can be used bi-directionally, which leads us to my second point…&lt;/p&gt;

&lt;p&gt;Sane dependency graphs are easier to achieve and sustain with such a structure. With namespaces, it is easy to construct dependency cycles (&lt;a href="http://www.infoq.com/articles/NDepend"&gt;that’s bad&lt;/a&gt;, mmkay?). With this pattern, the equivalent would be to build mega-components, which are an easier problem to spot than a decay into inter-dependent namespaces, for which you need &lt;a href="http://www.ndepend.com/"&gt;specialized tools&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I really like this pattern very much, and I would like to see more environments implement it. One could argue that dependency injection has some commonalities with this for example. What do you think? This is the half-baked result of some morning shower reflections, and I’d love to read your thoughts about it. What am I missing?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8888702" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Dynamic+languages/default.aspx">Dynamic languages</category></item><item><title>A quick guide to the built-in Orchard modules</title><link>http://weblogs.asp.net/bleroy/archive/2012/07/16/a-quick-guide-to-the-built-in-orchard-modules.aspx</link><pubDate>Mon, 16 Jul 2012 11:35:05 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8745810</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8745810</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/07/16/a-quick-guide-to-the-built-in-orchard-modules.aspx#comments</comments><description>&lt;p&gt;With the imminent release of Orchard 1.5, the number of built-in modules in the default distribution is getting quite impressive, if not intimidating. Now may be a good time to give new and old users a tour of what comes out of the box. Who knows, we may discover a hidden nugget or two along the way…&lt;/p&gt;  &lt;p&gt;I just finished writing a massive documentation topic that describes all Orchard features that come with the source code and WebPI distributions:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://docs.orchardproject.net/Documentation/Builtin-features"&gt;All built-in Orchard modules described&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I added the guide to the official Orchard documentation site. It details what modules come in the default package, which are only available from the source code package or from the gallery, and also mentions which are enabled by default.&lt;/p&gt;  &lt;p&gt;Documentation, like everything in Orchard, is open source, so you can contribute to this topic and others: &lt;a href="https://github.com/OrchardCMS/OrchardDoc/blob/131e204d65293549c8dd838c2a08a0aaf88f97ab/Documentation/Builtin-Features.markdown"&gt;Edit this topic&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I hope this helps.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8745810" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>My Body Summary template for Orchard</title><link>http://weblogs.asp.net/bleroy/archive/2012/07/01/my-body-summary-template-for-orchard.aspx</link><pubDate>Mon, 02 Jul 2012 02:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8683519</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8683519</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/07/01/my-body-summary-template-for-orchard.aspx#comments</comments><description>&lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 3px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="(c) Bertrand Le Roy 2012" border="0" alt="(c) Bertrand Le Roy 2012" align="left" src="http://weblogs.asp.net/blogs/bleroy/image_75EB658D.png" width="244" height="164" /&gt;By default, when &lt;a href="http://orchardproject.net"&gt;Orchard&lt;/a&gt; displays a content item such as a blog post in a list, it uses a very basic summary template that removes all markup and then extracts the first 200 characters. Removing the markup has the unfortunate effect of removing all styles and images, in particular the image I like to add to the beginning of my posts.&lt;/p&gt;  &lt;p&gt;Fortunately, overriding templates in Orchard is a piece of cake. Here is the &lt;font face="Courier New"&gt;Common.Body.Summary.cshtml&lt;/font&gt; file that I drop into the &lt;font face="Courier New"&gt;Views/Parts&lt;/font&gt; folder of pretty much all Orchard themes I build:    &lt;pre class="csharpcode"&gt;@{ 
    Orchard.ContentManagement.ContentItem contentItem =
        Model.ContentPart.ContentItem;
    var bodyHtml = Model.Html.ToString();
    var more = bodyHtml.IndexOf(&lt;span class="str"&gt;&amp;quot;&amp;lt;!--more--&amp;gt;&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (more != -1) {
        bodyHtml = bodyHtml.Substring(0, more);
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt; {
        var firstP = bodyHtml.IndexOf(&lt;span class="str"&gt;&amp;quot;&amp;lt;p&amp;gt;&amp;quot;&lt;/span&gt;);
        var firstSlashP = bodyHtml.IndexOf(&lt;span class="str"&gt;&amp;quot;&amp;lt;/p&amp;gt;&amp;quot;&lt;/span&gt;);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (firstP &amp;gt;=0 &amp;amp;&amp;amp; firstSlashP &amp;gt; firstP) {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
        }
    }
    var body = &lt;span class="kwrd"&gt;new&lt;/span&gt; HtmlString(bodyHtml); 
}
&amp;lt;p&amp;gt;@body&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;@Html.ItemDisplayLink(T(&lt;span class="str"&gt;&amp;quot;Read more...&amp;quot;&lt;/span&gt;).ToString(), contentItem)&amp;lt;/p&amp;gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;This template does not remove any tags, but instead looks for an HTML comment delimiting the end of the post’s intro:
  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;&amp;lt;!--more--&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;This is the same convention that is being used in WordPress, and it’s easy to add from the source view in TinyMCE or Live Writer.&lt;/p&gt;

&lt;p&gt;If such a comment is not found, the template will extract the first paragraph (delimited by &lt;font face="Courier New"&gt;&amp;lt;p&amp;gt;&lt;/font&gt; and &lt;font face="Courier New"&gt;&amp;lt;/p&amp;gt;&lt;/font&gt; tags) as the summary.&lt;/p&gt;

&lt;p&gt;And if it finds neither, it will use the whole post.&lt;/p&gt;

&lt;p&gt;The template also adds a localizable link to the full post.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8683519" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Orchard/default.aspx">Orchard</category></item><item><title>Code is not the best way to draw</title><link>http://weblogs.asp.net/bleroy/archive/2012/06/22/code-is-not-the-best-way-to-draw.aspx</link><pubDate>Sat, 23 Jun 2012 00:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8635239</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8635239</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/06/22/code-is-not-the-best-way-to-draw.aspx#comments</comments><description>&lt;p&gt;It should be quite obvious: drawing requires constant visual feedback. Why is it then that we still draw with code in so many situations? Of course it’s because the low-level APIs always come first, and design tools are built after and on top of those. Existing design tools also don’t typically include complex UI elements such as buttons.&lt;/p&gt;  &lt;p&gt;When we launched our &lt;a href="http://nwazet.com/touch-display-module"&gt;Touch Display module&lt;/a&gt; for &lt;a href="http://nwazet.com/netduinogo"&gt;Netduino Go!&lt;/a&gt;, we naturally built APIs that made it easy to draw on the screen from code, but very soon, we felt the limitations and tedium of drawing in code. In particular, any modification requires a modification of the code, followed by compilation and deployment. When trying to set-up buttons at pixel precision, the process is not optimal.&lt;/p&gt;  &lt;p&gt;On the other hand, code is irreplaceable as a way to automate repetitive tasks. While tools like Illustrator have ways to repeat graphical elements, they do so in a way that is a little alien and counter-intuitive to my developer mind. From these reflections, I knew that I wanted a design tool that would be structurally code-centric but that would still enable immediate feedback and mouse adjustments.&lt;/p&gt;  &lt;p&gt;While thinking about the best way to achieve this goal, I saw this fantastic video by Bret Victor:&lt;/p&gt; &lt;iframe height="281" src="http://player.vimeo.com/video/36579366?byline=0" frameborder="0" width="500" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;The key to the magic in all these demos is permanent execution of the code being edited. Whenever a parameter is being modified, everything is re-executed immediately so that the impact of the modification is instantaneously visible. If you do this all the time, the code and the result of its execution fuse in the mind of the user into dual representations of a single object. All mental barriers disappear. It’s like magic.&lt;/p&gt;  &lt;p&gt;The tool I built, Nutshell, is just another implementation of this principle. It manipulates a list of graphical operations on the screen. Each operation has a nice editor, and translates into a bit of code. Any modification to the parameters of the operation will modify the bit of generated code and trigger a re-execution of the whole program. This happens so fast that it feels like the drawing reacts instantaneously to all changes.&lt;/p&gt; &lt;iframe height="281" src="http://www.youtube.com/embed/QKKfqGHRoRU" frameborder="0" width="500" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;The order of the operations is also the order in which the code gets executed. So if you want to bring objects to the front, move them down in the list, and up if you want to move them to the back:&lt;/p&gt; &lt;iframe height="281" src="http://www.youtube.com/embed/xsOOEUSNSSk" frameborder="0" width="500" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;But where it gets really fun is when you start applying code constructs such as loops to the design tool. The elements that you put inside of a loop can use the loop counter in expressions, enabling crazy scenarios while retaining the real-time edition features.&lt;/p&gt; &lt;iframe height="281" src="http://www.youtube.com/embed/cVb7_jRFU00" frameborder="0" width="500" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;When you’re done building, you can just deploy the code to the device and see it run in its native environment:&lt;/p&gt; &lt;iframe height="281" src="http://www.youtube.com/embed/rLxgI-kM-fg" frameborder="0" width="500" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p&gt;This works thanks to two code generators. The first code generator is building JavaScript that is executed in the browser to build the canvas view in the web page hosting the tool. The second code generator is building the C# code that will run on the Netduino Go! microcontroller and that will drive the display module.&lt;/p&gt;  &lt;p&gt;The possibilities are fascinating, even if you don’t care about driving small touch screens from microcontrollers: it is now possible, within a reasonable budget, to build specialized design tools for very vertical applications. Direct feedback is a powerful ally in many domains. Code generation driven by visual designers has become more approachable than ever thanks to extraordinary JavaScript libraries and to the powerful development platform that modern browsers provide.&lt;/p&gt;  &lt;p&gt;I encourage you to tinker with &lt;a href="http://nwazet.com/nutshell"&gt;Nutshell&lt;/a&gt; and let it open your eyes to new possibilities that you may not have considered before. &lt;a href="https://github.com/nwazet/Nwazet.Nutshell"&gt;It’s open source&lt;/a&gt;. And of course, my company, &lt;a href="http://nwazet.com"&gt;Nwazet&lt;/a&gt;, can help you develop your own custom browser-based direct feedback design tools. This is real visual programming…&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8635239" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Nwazet/default.aspx">Nwazet</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/canvas/default.aspx">canvas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/nutshell/default.aspx">nutshell</category></item><item><title>Azure Web Sites FTP credentials</title><link>http://weblogs.asp.net/bleroy/archive/2012/06/12/azure-web-sites-ftp-credentials.aspx</link><pubDate>Tue, 12 Jun 2012 19:34:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8600228</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=8600228</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2012/06/12/azure-web-sites-ftp-credentials.aspx#comments</comments><description>&lt;p&gt;A quick tip for all you new enthusiastic users of the amazing new Azure. I struggled for a few minutes finding this, so I thought I’d share. The Azure dashboard doesn’t seem to give easy access to your FTP credentials, and they are not the login and password you use everywhere else. What Azure does give you though is a Publish Profile that you can download:&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Download publish profile" border="0" alt="Download publish profile" src="http://weblogs.asp.net/blogs/bleroy/image_41773EB6.png" width="217" height="137" /&gt;&lt;/p&gt;  &lt;p&gt;This is a plain XML file that should look something like this:   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;publishData&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;publishProfile&lt;/span&gt;
    &lt;span class="attr"&gt;profileName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;nameofyoursite - Web Deploy&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;publishMethod&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MSDeploy&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;publishUrl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;waws-prod-blu-001.publish.azurewebsites.windows.net:443&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;msdeploySite&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;nameofyoursite&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;userName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;$NameOfYourSite&amp;quot;&lt;br /&gt;    &lt;/span&gt;&lt;span class="attr"&gt;userPWD&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;sOmeCrYPTicL00kIngStr1nG&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;destinationAppUrl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://nameofyoursite.azurewebsites.net&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;SQLServerDBConnectionString&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;mySQLDBConnectionString&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;hostingProviderForumLink&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;controlPanelLink&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://windows.azure.com&amp;quot;&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;databases&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;publishProfile&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;publishProfile&lt;/span&gt;
    &lt;span class="attr"&gt;profileName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;nameofyoursite - FTP&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;publishMethod&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;FTP&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;publishUrl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ftp://&lt;font style="background-color: #ffff00"&gt;waws-prod-blu-001.ftp.azurewebsites.windows.net&lt;/font&gt;/site/wwwroot&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;ftpPassiveMode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;userName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&lt;font style="background-color: #ffff00"&gt;nameofyoursite\$nameofyoursite&lt;/font&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;userPWD&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&lt;font style="background-color: #ffff00"&gt;sOmeCrYPTicL00kIngStr1nG&lt;/font&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;destinationAppUrl&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://nameofyoursite.azurewebsites.net&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;SQLServerDBConnectionString&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;mySQLDBConnectionString&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;hostingProviderForumLink&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;controlPanelLink&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://windows.azure.com&amp;quot;&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;databases&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;publishProfile&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;publishData&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;I’ve highlighted the FTP server name, user name and password. This is what you need to use in Filezilla or whatever you use to access your site remotely. Notice how the password looks encrypted. Well, it’s not really encrypted in fact. This is your password in clear text. It’s just crypto-random gibberish, which is the best kind of password.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;UPDATE:&lt;/b&gt; About 2 minutes after I posted that, David Ebbo mentioned to me on Twitter that if you've configured publishing credentials (for Git typically) those will work too. Don't forget to include the full user name though, which should be of the form nameofthesite\username. The password is the one you defined.&lt;/p&gt;

&lt;p&gt;That’s it. Enjoy.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8600228" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Azure/default.aspx">Azure</category></item></channel></rss>