<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Coding in the cloud</title>
	<atom:link href="http://joeriks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://joeriks.com</link>
	<description>Jonas Eriksson (@joeriks) about web programming</description>
	<lastBuildDate>Sat, 28 Jan 2012 17:49:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='joeriks.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/de130fb9c93626140637e0ebadf04954?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Coding in the cloud</title>
		<link>http://joeriks.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://joeriks.com/osd.xml" title="Coding in the cloud" />
	<atom:link rel='hub' href='http://joeriks.com/?pushpress=hub'/>
		<item>
		<title>A look at the basic parts of building a site with Umbraco 5 RC2</title>
		<link>http://joeriks.com/2012/01/12/a-look-at-the-basic-parts-of-building-a-site-with-umbraco-5-rc2/</link>
		<comments>http://joeriks.com/2012/01/12/a-look-at-the-basic-parts-of-building-a-site-with-umbraco-5-rc2/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 12:18:22 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Umbraco Jupiter]]></category>

		<guid isPermaLink="false">http://joeriks.com/?p=1565</guid>
		<description><![CDATA[I&#8217;ve been using Umbraco 4 for a good while and am already sold on the CMS. I&#8217;ve built and are maintaining a few sites and are happy with most of the Umbraco functionality. Now Umbraco 5 (aka Jupiter) is knocking at the door, RC2 was just released, and it looks really promising. The whole CMS [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1565&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>I&#8217;ve been using Umbraco 4 for a good while and am already sold on the CMS. I&#8217;ve built and are maintaining a few sites and are happy with most of the Umbraco functionality.<br />
</strong></p>
<p>Now Umbraco 5 (aka Jupiter) is knocking at the door, RC2 was just released, and it looks really promising. The whole CMS has been rewritten using Asp Net MVC3 instead of Webforms, and with modern standard dev architectures.</p>
<p>Umbraco 5 current status <a href="http://umbraco.com/umbraco-5-status.aspx">http://umbraco.com/umbraco-5-status.aspx</a></p>
<p>I have been postponing my attempts to do a real dive into Umbraco 5, but now it&#8217;s really time, and where to start? With the basics of course &#8211; so in this article I&#8217;ll describe my first try building a raw site with the basic components.</p>
<p>I thought it might be of interest for those of you that are interested in what&#8217;s up with this Umbraco thing and want to check out the 5 even if you did not look at it before. And for those of you who are old timers and want a very quick review of Jupiter from a site builder perspective.</p>
<p>Did I say basic? Yes.</p>
<p><em>Disclaimer &#8211; I like to write as I learn new stuff. I&#8217;m new to Jupiter and might have been missing important parts that should be noted in this article. If I did I will be very grateful if you, dear reader, contact me, here or otherwhere.</em></p>
<h3>Installation process</h3>
<p>Short version : <strong>Download</strong> the RC2, unblock the zip, <strong>unzip</strong> it, <strong>open</strong> it as a website in WebMatrix. <strong>Run it</strong>, and go through the <strong>installation</strong> process, choose Sql CE as the database. No problems. The same good looking installation UI as in version 4.</p>
<p>I started two parallell sites, one with the provided starter kit and one without it. The starter kit for help and reference and the empty site for my experiment.</p>
<h3>UI Gotchas</h3>
<p>Gotchas? &#8230; nope, did not find any&#8230; The UI looks pretty much the same as in Umbraco 4 which of course makes perfect sense as it has proved to work very good for devs, admins and editors.</p>
<p>I know they have been putting lot of effort into the UI, and it shows, it has a very nice and professional user experience feeling. And as in v4, and probably even more so now, it is extensible. Be sure that many devs in the Umbraco community are busy developing valuable addons/packages as we speak.</p>
<p><a href="http://joeriks.files.wordpress.com/2012/01/jupiter-get-started.png"><img class="size-medium wp-image-1604 alignnone" style="border-color:initial;border-style:initial;" title="jupiter-get-started" src="http://joeriks.files.wordpress.com/2012/01/jupiter-get-started.png?w=600" alt="" /></a></p>
<p>(And you can right click a section and open in a new tab in the browser again&#8230; yay!)</p>
<h3>The Trinity</h3>
<p><img class="alignright" style="border-color:initial;border-style:initial;" title="Trinity" src="http://rooot.blogg.se/images/2011/34002-trinity_matrix_169056716.jpg" alt="" width="50" height="65" /></p>
<p>To build a visible web page with the help of Umbraco 5 we need at least three things just like before:<strong> a document type</strong> (defines the dynamic elements),<strong> a template</strong> (the html with placeholders for dynamic elements basically) and a <strong>content document</strong> (with values for the dynamic elements).</p>
<h3>Document type</h3>
<p>I added a Content document type with the two properties <strong>header</strong> (textstring) and <strong>body text</strong> (rich text editor):</p>
<p><a href="http://joeriks.files.wordpress.com/2012/01/jupiter-content.png"><img class="size-medium wp-image-1572 alignnone" title="jupiter-content" src="http://joeriks.files.wordpress.com/2012/01/jupiter-content.png?w=600" alt="" /></a></p>
<p>Very similar to Umbraco 4. Some nice new details to the UI gives it a newish and fresh feeling.</p>
<p>To separate the site start node from content documents I also added a <strong>Home Page</strong> document type, with only the name and the icon and the properties inherited from the Content document type.</p>
<p><strong>Inherit from several document types</strong></p>
<p>Here&#8217;s a new cool thing : you can have document types inherit properties and tabs from not only one but several different parent document types. And you can change those whenever you like. That makes a big difference when it comes to how easy it is to manage the content structure on a big site.<br />
<a href="http://joeriks.files.wordpress.com/2012/01/jupiter-home-doctype1.png"><img class="size-medium wp-image-1580 alignnone" title="jupiter-home-doctype" src="http://joeriks.files.wordpress.com/2012/01/jupiter-home-doctype1.png?w=600" alt="" /></a></p>
<h3>Templates</h3>
<p>These are changed in Umbraco 5. In 4 we had the Webforms MasterPage-templates. But now we have the new cool kid in town &#8211;  MVC3 Razor <strong>Views</strong> and <strong>Layouts</strong>, which makes templating really easy and flexible. As it is standards you will be able to use ready made MVC3 and/razor templates and just add the umbraco parts.</p>
<p>A view includes a reference to a layout and functions to render the dynamic contents, add content &#8220;fields&#8221; using the tool in the toolbar or by writing: @Umbraco.Field(&#8220;header&#8221;) and @Umbraco.Field(&#8220;bodyText&#8221;):<br />
<a href="http://joeriks.files.wordpress.com/2012/01/jupiter-view.png"><img class="alignnone size-medium wp-image-1575" title="jupiter-view" src="http://joeriks.files.wordpress.com/2012/01/jupiter-view.png?w=600" alt="" /></a></p>
<p>And a layout contains the base html with a @RenderBody() call which renders the view contents. A layout can have another layout by itself if necessary.</p>
<p><a href="http://joeriks.files.wordpress.com/2012/01/jupiter-layout.png"><img class="alignnone size-medium wp-image-1576" title="jupiter-layout" src="http://joeriks.files.wordpress.com/2012/01/jupiter-layout.png?w=600" alt="" /></a></p>
<p>To the layout I also added a simple css-file in Settings &gt; Styles. The css got the path /content/styles/stylesheet.css</p>
<h3>Content</h3>
<p>I added a Home page node in the content section, wrote text for header and body text (same html editing capabilities as in v4 and many other CMS&#8217;es with the Tinymce), and the similar for a sub content page.</p>
<p>I also added an image with the help of the image tool. The image tool has been changed a bit since v4, and works well, but I bet there will be packages which will help us to have a really nice touch to image handling eventually.</p>
<p><a href="http://joeriks.files.wordpress.com/2012/01/jupiter-content-2.png"><img class="alignnone size-medium wp-image-1583" title="jupiter-content-2" src="http://joeriks.files.wordpress.com/2012/01/jupiter-content-2.png?w=600" alt="" /></a></p>
<p><strong>Now we have a result</strong></p>
<p><strong></strong>Viewing the site as is:<br />
<a href="http://joeriks.files.wordpress.com/2012/01/jupiter-browse-homepage.png"><img class="alignnone size-medium wp-image-1584" title="jupiter-browse-homepage" src="http://joeriks.files.wordpress.com/2012/01/jupiter-browse-homepage.png?w=600" alt="" /></a></p>
<h3>A navigation macro?</h3>
<p>Umbraco 5 has macros, which I did not look at very much yet. But for stuff like navigations it&#8217;s enough (and easy) to create a small razor file and add is as a <strong>Partial</strong> which can be rendered wherever in a layout (or a view), I took this from the starter template:<br />
<a href="http://joeriks.files.wordpress.com/2012/01/jupiter-partial-navigation.png"><img class="alignnone size-medium wp-image-1585" title="jupiter-partial-navigation" src="http://joeriks.files.wordpress.com/2012/01/jupiter-partial-navigation.png?w=600" alt="" /></a></p>
<p>&#8230; and added it to the right place in my layout with the code @Html.Partial(&#8220;Navigation&#8221;) et voila:</p>
<p><a href="http://joeriks.files.wordpress.com/2012/01/jupiter-content-with-navigation.png"><img class="alignnone size-medium wp-image-1587" title="jupiter-content-with-navigation" src="http://joeriks.files.wordpress.com/2012/01/jupiter-content-with-navigation.png?w=600" alt="" /></a></p>
<p>For the section to the right I added another document type &#8220;Section content&#8221; with just a rich text editor property named sidebarText and made my other document types inherit from that one, then I defined a section in the layout and added the @Umbraco.Field(&#8220;sidebarText&#8221;)</p>
<p style="padding-left:30px;"><em><strong>About the difference between Partial and a Macro</strong></em></p>
<p style="padding-left:30px;"><em>Umbraco 5 Lead Architect Alex Norcliffe just answered the question on twitter, &#8220;Partial is small reusable piece you can put in many templates, &amp; a Macro Partial is one that can have user params e.g. in an RTE&#8221; (rte = rich text editor). And Umbraco HQ &amp; Core developer Matt Brailsford added &#8221;MacroPartials have extra editor requirements, we made an explicit split, and housed the Macro Partials next to the Macro definitions. Kinda like usercontrols in v4, they don&#8217;t have to be macros, but then can be to allow user config. We just have an explicit split so it&#8217;s clear what they are used for and house them closest to those that use them Partials &gt; Templates, Macro Partials &gt; Macros.&#8221; Which also means the permissions differ, a designer can for example be allowed to access the Settings section and change Template Partials but not the Developer section where Macro Partials is.</em></p>
<h3>Conclusion</h3>
<p>I did not stumble on any thing doing this basic site setup, everything worked as I was expecting or was easy to figure out. I know there are still things they are working on, and the RC2 is still a RC so not ready for production yet. But they definately seem to have nailed the most importand parts, and have a solid ground for a great CMS. MVC3 is a darn good framework, used by many. And Razor simply rocks. So &#8211; what&#8217;s keeping you?</p>
<p><a href="https://twitter.com/#!/joeriks/status/157442677493858304">https://twitter.com/#!/joeriks/status/157442677493858304</a></p>
<p>Umbraco 5 current status <a href="http://umbraco.com/umbraco-5-status.aspx">http://umbraco.com/umbraco-5-status.aspx</a></p>
<h3>Further reading &#8211; from a site builder perspective</h3>
<p>What is V5 <a href="http://umbraco.com/umbraco-5-status/what-is-v5.aspx">http://umbraco.com/umbraco-5-status/what-is-v5.aspx</a></p>
<p>To get a good understanding of how the layout system work have a look at the descriptions for MVC 3 Razor layouts, for example <a href="http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx">http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx</a></p>
<p>Umbraco 5 gems for content editors <a href="http://umbraco.com/follow-us/blog-archive/2011/7/8/umbraco-5-gems-for-content-editors.aspx">http://umbraco.com/follow-us/blog-archive/2011/7/8/umbraco-5-gems-for-content-editors.aspx</a></p>
<p>Well basically: <a href="http://umbraco.com/follow-us/blog-archive.aspx">http://umbraco.com/follow-us/blog-archive.aspx</a> :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1565/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1565&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2012/01/12/a-look-at-the-basic-parts-of-building-a-site-with-umbraco-5-rc2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-get-started.png?w=600" medium="image">
			<media:title type="html">jupiter-get-started</media:title>
		</media:content>

		<media:content url="http://rooot.blogg.se/images/2011/34002-trinity_matrix_169056716.jpg" medium="image">
			<media:title type="html">Trinity</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-content.png?w=600" medium="image">
			<media:title type="html">jupiter-content</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-home-doctype1.png?w=600" medium="image">
			<media:title type="html">jupiter-home-doctype</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-view.png?w=600" medium="image">
			<media:title type="html">jupiter-view</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-layout.png?w=600" medium="image">
			<media:title type="html">jupiter-layout</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-content-2.png?w=600" medium="image">
			<media:title type="html">jupiter-content-2</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-browse-homepage.png?w=600" medium="image">
			<media:title type="html">jupiter-browse-homepage</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-partial-navigation.png?w=600" medium="image">
			<media:title type="html">jupiter-partial-navigation</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2012/01/jupiter-content-with-navigation.png?w=600" medium="image">
			<media:title type="html">jupiter-content-with-navigation</media:title>
		</media:content>
	</item>
		<item>
		<title>Using SignalR with Umbraco to broadcast messages (or chat) [15 minutes]</title>
		<link>http://joeriks.com/2011/11/21/using-signalr-with-umbraco-to-broadcast-messages-or-chat-15-minutes/</link>
		<comments>http://joeriks.com/2011/11/21/using-signalr-with-umbraco-to-broadcast-messages-or-chat-15-minutes/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 12:33:29 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Hackaton]]></category>
		<category><![CDATA[WebSockets]]></category>

		<guid isPermaLink="false">http://joeriks.com/?p=1520</guid>
		<description><![CDATA[My goal with this is to have a way to send messages from running tasks to me (and other admins) using a broadcast method &#8230; aswell as have some fun playing with SignalR which looks really cool . Just by adding the SignalR dll and js files and some minimal code you&#8217;ll get started with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1520&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>My goal with this is to have a way to send messages from running tasks to me (and other admins) using a broadcast method &#8230; aswell as have some fun playing with <a href="https://github.com/SignalR/SignalR"> SignalR which looks really cool <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </a>.</p>
<p>Just by adding the SignalR dll and js files and some minimal code you&#8217;ll get started with SignalR within an Umbraco application in 15 minutes.</strong></p>
<p><strong>Installation</strong><br />
1. Either download and install my little <a href="http://xapp.se/usignalr_01.zip">uSignalR experimental package</a> (SignalR files from 2011-11-21) or run the SignalR Nuget to get fresh files from the source, and add the myconnection.cs and the two templates as shown below.</p>
<p>2. I could not find out how to add a reserved url to the web.config using package actions, so you will need to add ~/echo manually in your <strong>web.config</strong>:</p>
<p><pre class="brush: plain;">
...
&lt;appSettings&gt;
...
&lt;add key=&quot;umbracoReservedUrls&quot; value=&quot;~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/echo&quot;/&gt;
...
</pre></p>
<p>Then just open the /mysite/recieve page in two (or more) browsers and start &#8220;chatting&#8221;. And to try the server send functionality &#8211; open the /mysite/send page . You can see the code here below. To read more and explore the possibilities : look at the <a href="https://github.com/SignalR/SignalR/wiki">SignalR wiki</a></p>
<h3>Brief explanation of the parts that makes it happen</h3>
<p>In <strong>/App_Code/MyConnection.cs</strong> we hook up the connection which listens to messages and broadcasts them to the listeners.</p>
<p><pre class="brush: plain;">using System;
using System.Threading.Tasks;
using SignalR;

public class MyConnection : PersistentConnection
{
    protected override Task OnReceivedAsync(string clientId, string data)
    {
        return Connection.Broadcast(data);
    }
}

public class MySignalRRoute : umbraco.BusinessLogic.ApplicationBase
{
    public MySignalRRoute()
    {
        SignalR.Routing.RouteExtensions.MapConnection&lt;MyConnection&gt;(System.Web.Routing.RouteTable.Routes, &quot;echo&quot;, &quot;echo/{*operation}&quot;);
    }
}</pre></p>
<p>In the <strong>&#8220;Send&#8221; Template</strong> we just send messages to all listeners.</p>
<p><pre class="brush: plain;">&lt;asp:Content ContentPlaceHolderID=&quot;ContentPlaceHolderDefault&quot; runat=&quot;server&quot;&gt;
&lt;umbraco:macro runat=&quot;server&quot; language=&quot;cshtml&quot;&gt;
@{
    SignalR.Connection.GetConnection&lt;MyConnection&gt;().Broadcast(&quot;This is a message from the server&quot;);   
}
&lt;/umbraco:macro&gt;
&lt;/asp:Content&gt;
</pre></p>
<p>The <strong>&#8220;Recieve&#8221; Template</strong> is only html + javascript which lets the users send and listen to messages.</p>
<p><pre class="brush: plain;">&lt;asp:Content ContentPlaceHolderID=&quot;ContentPlaceHolderDefault&quot; runat=&quot;server&quot;&gt;

&lt;script src=&quot;http://code.jquery.com/jquery-1.7.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;Scripts/jquery.signalR.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

    $(function () {

        var connection = $.connection('echo');
        connection.received(function (data) {
            $('#messages').append('&lt;li&gt;' + data + '&lt;/li&gt;');
        });

        connection.start();

        $(&quot;#broadcast&quot;).click(function () {
            connection.send($('#msg').val());
        });
    });
&lt;/script&gt;

&lt;input type=&quot;text&quot; id=&quot;msg&quot; /&gt;
&lt;input type=&quot;button&quot; id=&quot;broadcast&quot; value=&quot;broadcast&quot; /&gt;

&lt;ul id=&quot;messages&quot;&gt;
&lt;/ul&gt;
&lt;/asp:Content&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1520/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1520&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/11/21/using-signalr-with-umbraco-to-broadcast-messages-or-chat-15-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>Separating html and logic in Razor (WebPages or Umbraco macroscript)</title>
		<link>http://joeriks.com/2011/11/06/separating-html-and-logic-in-razor-webpages-or-umbraco-macroscript/</link>
		<comments>http://joeriks.com/2011/11/06/separating-html-and-logic-in-razor-webpages-or-umbraco-macroscript/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 18:03:55 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Razor]]></category>
		<category><![CDATA[WebMatrix]]></category>

		<guid isPermaLink="false">http://joeriks.com/?p=1455</guid>
		<description><![CDATA[Mixing logic and html can easily end up with messy, hard-to-maintain code. In MVC it&#8217;s easy to separate the parts with the controller / view-separation. But how to do it nicely in WebPages or in an Umbraco macroscript? Ultimately I want my Razor to be free from variable assignments other than for loop iterators function [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1455&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Mixing logic and html can easily end up with messy, hard-to-maintain code. In MVC it&#8217;s easy to separate the parts with the controller / view-separation. But how to do it nicely in WebPages or in an Umbraco macroscript?</strong></p>
<blockquote><p>Ultimately I want my Razor to be free from
<ul>
<li>variable assignments other than for loop iterators</li>
<li>function calls other than formatting and html helpers</li>
<li>usage of data outside of the &#8220;ViewModel&#8221;</li>
</ul>
</blockquote>
<p>I have some WebPages and Umbraco projects with some quite advanced razor code and I&#8217;ve been having many doubts about how I mix logic in my razor code. I try to separate it, most often by placing logic at the top, but still using Razor (with helpers or RenderPage by all means). After re-thinking some about the @functions ability in Razor and found out about the overridable InitializePage function I feel I now have a better more solid structure to use.</p>
<p>The idea is simply this : remove all logic (but necessary iterations and some conditions) from the razor, and place it in the @functions part (in the InitializePage function) together with ViewModel properties. The ViewModel properties should contain all data that the view part needs to be able to render the page / the macro. And the view part should not access anything else than the ViewModel properties:</p>
<p><pre class="brush: plain;">@* --- The logic-less view part: --- *@

&lt;p&gt;@SomeProperty&lt;/p&gt;

@* --- The controller / viewmodel constructor part: --- *@

@functions{

  // the properties of the view model:
  public string SomeProperty {get; set;}

  // taking care of post data and constructing the view model:
  protected override void InitializePage()
  {
    // make up the &quot;ViewModel&quot; properties
    SomeProperty = &quot;some data&quot;;
  } 
}
</pre></p>
<h3>Advantages with this approach</h3>
<ul>
<li>A clear separation of view and logic (not as clear as having them in separate files tho)</li>
<li>The logic is pure C#-code, no risk of doing mistakes due to misplaced @&#8217;s (and missing code blocks)</li>
<li>The code is a big step towards MVC, and the full step will be quite easy later on if necessary</li>
<li>Minimal added whitespace in page source</li>
</ul>
<p><i>Helpers are perfectly fine to add to this &#8211; but just as with the view code, I think any logic but view logic should be left out of them.</i></p>
<h3>A remake of my &#8220;old skool&#8221; contact form sample</h3>
<p>I wrote a contact form razor sample <a href="http://joeriks.com/2011/01/04/playing-with-razor-in-umbraco-an-old-skool-contact-form/">quite a while ago</a>, guilty of mixing logic into the view. However I&#8217;m not the only one <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , <a href="http://www.asp.net/webmatrix/tutorials/4-working-with-forms">a sample at asp.net</a>.</p>
<p>Here&#8217;s a better (I think) remake, using the initializepage-structure:<br />
<pre class="brush: plain;">&lt;h2&gt;Contact form&lt;/h2&gt;

@if(ShowMessage)
{
   &lt;div&gt;&lt;strong&gt;@Message&lt;/strong&gt;&lt;/div&gt;
}
@if(ShowForm)
{
   &lt;form action=&quot;#&quot; method=&quot;post&quot;&gt;
     &lt;div&gt;
       &lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;
       &lt;input id=&quot;name&quot; name=&quot;name&quot; value=&quot;@PostedName&quot;/&gt;
     &lt;/div&gt;
     &lt;div&gt;
       &lt;label for=&quot;message&quot;&gt;Message:&lt;/label&gt;
       &lt;textarea id=&quot;message&quot; name=&quot;message&quot;&gt;@PostedMessage&lt;/textarea&gt;
     &lt;/div&gt;
     &lt;input type=&quot;submit&quot; value=&quot;Post message&quot;/&gt;
 
   &lt;/form&gt;
}


@functions{
  public bool ShowForm {get; set;}
  public bool ShowMessage {get; set;}      
  public string Message {get; set;}
  public string PostedName {get; set;}
  public string PostedMessage {get; set;}
           
  protected override void InitializePage() 
  {
    if (!IsPost) 
    {
       ShowForm = true;
       ShowMessage = false;
    }
    else
    {
       PostedName = Request[&quot;name&quot;];
       PostedMessage = Request[&quot;message&quot;];
       var IsValid = (!string.IsNullOrEmpty(PostedName) &amp;amp;&amp;amp; !string.IsNullOrEmpty(PostedMessage));
       if (IsValid)
       {
         var bodyText = &quot;Message from &quot; + PostedName + Environment.NewLine + PostedMessage;
         umbraco.library.SendMail(&quot;from@mysite.com&quot;,&quot;admin@mysite.com&quot;,&quot;New message&quot;, bodyText,false);
         Message = &quot;Thank you &quot; + PostedName + &quot; for posting a message&quot;;
         ShowForm = false;
         ShowMessage = true;
       }
       else
       {
         Message = &quot;You need to enter both name and message&quot;;
         ShowForm = true;
         ShowMessage = true;
       }
    }
  }
}</pre></p>
<p><i><strong>Public properties or private fields?</strong><br />
The public properties could be private fields without any problem (in these samples), the reason I choose public properties is that I like to resemble the MVC structure as far as possible.</i></p>
<h3>Responding to an ajax-post</h3>
<p>This structure also makes it really easy to handle and respond to ajax posts to the same form (this can only be done in a pure WebPages razor, not Umbraco macro as that does handle the Response output the same way) :<br />
<pre class="brush: plain;">
    ... in the validated post part ...
    if (IsAjax)
    {
        Json.Write(new {
          postValid = true,
          message = Message
          }, Response.Output);
    }</pre></p>
<p>In Umbraco the options for ajax are to either to run razor script outside of the Umbraco context (use WebPages + add reservedpath in web.config) or to make a separate &#8220;ajaxresult-template&#8221; with a razor call:</p>
<h3>Bonus: posting the form with ajax in Umbraco</h3>
<p>Using this method you can return json directly from your razor script in Umbraco. The tricky part is we dont want to return the surrounding template parts, and for simplicity we want to use code in the same razor script as as we already are in.</p>
<p>Add a template &#8211; call it <strong>AjaxRazor</strong> &#8211; which will be responsible for rendering the razor without anything but the script result (we add an if IsAjax condition to have some kind of security against unintended run script files, please add more security checks for posts on a live site):<br />
<pre class="brush: plain;">&lt;%@ Master Language=&quot;C#&quot; MasterPageFile=&quot;~/umbraco/masterpages/default.master&quot; AutoEventWireup=&quot;true&quot; %&gt;

&lt;asp:Content ContentPlaceHolderID=&quot;ContentPlaceHolderDefault&quot; runat=&quot;server&quot;&gt;
  &lt;umbraco:macro language=&quot;cshtml&quot; runat=&quot;server&quot;&gt;
    @if (IsAjax){
      var path = Request[&quot;path&quot;];
      if (!path.StartsWith(&quot;~&quot;)) { path = umbraco.IO.SystemDirectories.MacroScripts + &quot;/&quot; + path;}
      @RenderPage(path)   
    }
  &lt;/umbraco:macro&gt;
&lt;/asp:Content&gt;</pre></p>
<p>Now it&#8217;s possible to run any razor script using the url /AjaxRazor?path={path-to-script}</p>
<p>Next make the form post it&#8217;s contents to the template, with the razor script path as a querystring parameter, we get that path with the help of the page property VirtualPath:</p>
<p><pre class="brush: plain;">@if(showOnlyJson)
{
  Json.Write(json, Response.Output);
}
else 
{
 if(showForm)
 {
 &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function() {
  $('form').submit(function() {
  $.post('@ajaxPostPath', 
      $(this).serialize(), 
      function(data){
         alert(data);
      });
  return false;
 });
 });
 &lt;/script&gt;

 &lt;form method=&quot;post&quot; action=&quot;#&quot;&gt;
 &lt;input type=&quot;text&quot; name=&quot;name&quot;/&gt;
 &lt;input type=&quot;submit&quot;/&gt;
 &lt;/form&gt;
 }
 if (showMessage)
 {
   &lt;p&gt;@message&lt;/p&gt;
 }
}
@functions{
 private bool showOnlyJson;
 private bool showMessage;
 private bool showForm;
 private string message;
 private object json;
 private string ajaxPostPath;
 protected override void InitializePage()
 {
   if(IsPost)
   {
      var postedName = Request[&quot;name&quot;];
      message = &quot;Thanks for posting&quot;;
      if (IsAjax)
      {
       showOnlyJson = true;
       json = new {message=message, name = postedName};
      }
      else
      {
       showMessage = true;
       showForm = false;
      }
   }
   else
   {
       showForm = true;
       ajaxPostPath = &quot;/AjaxRazor?path=&quot; + VirtualPath; 
   }
 }         
}</pre></p>
<h3>Umbraco v5</h3>
<p>I believe this approach still might be useful in Umbraco v5. It should likely not be recommended as an option for advanced solutions, but for simple forms (and advanced navigations) I think its suitable. And even if it&#8217;s not suitable it&#8217;s a good step towards controllers and viewmodels.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1455/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1455&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/11/06/separating-html-and-logic-in-razor-webpages-or-umbraco-macroscript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>A nice deploy approach : Umbraco 5 alpha at AppHarbor [experimental]</title>
		<link>http://joeriks.com/2011/11/05/a-nice-deploy-approach-umbraco-5-alpha-appharbor-experimental/</link>
		<comments>http://joeriks.com/2011/11/05/a-nice-deploy-approach-umbraco-5-alpha-appharbor-experimental/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 12:06:57 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[AppHarbor]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1407</guid>
		<description><![CDATA[AppHarbor is an interesting service that can deploy and host an Asp.Net application really easy. They use the slogan &#8220;Azure done right&#8221;. I&#8217;m still in an experimental mode with it. But it passed my &#8220;if I cannot get this going in less than 1 hour I&#8217;ll skip it&#8221;- test easily. Azure didn&#8217;t. The pricing is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1407&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>AppHarbor is an interesting service that can deploy and host an Asp.Net application really easy. They use the slogan &#8220;Azure done right&#8221;. I&#8217;m still in an experimental mode with it. But it passed my &#8220;if I cannot get this going in less than 1 hour I&#8217;ll skip it&#8221;- test easily. Azure didn&#8217;t.</p>
<p>The pricing is also a pleasant detail : no cost at all for a single server instance. So for trying out stuff it&#8217;s really ideal. Oh, and deploy is as easy as a Git commit and push. *happy face*</strong></p>
<p>Here&#8217;s an example as how you can use it to host an Umbraco 5 alpha:</p>
<h3>1. Get your Umbraco website running locally</h3>
<p>1.1 Download and extract an Umbraco prebuilt web application of your choice (nightly / alpha or whatever is available) (<a href="http://umbraco.codeplex.com/releases/view/75489">Alpha 3</a>)</p>
<blockquote><p>You should even be able use the full Umbraco project &#8211; as AppHarbor has a automatic build process. Would be cool if someone tried it. I went the easy path and only used the pre-built nightly to get going quickly.</p></blockquote>
<p>1.2 Run the Umbraco site in WebMatrix (right click the extracted folder and choose &#8220;open as a website in WebMatrix) go through the installation and choose the SQL CE database option as it requires no extra configuration. You can use a full SQL database if you need, AppHarbor has such as an add on.</p>
<blockquote><p>You <strong>can</strong> do the Umbraco site installation online at AppHarbor, but that is not recommended as you will miss the possibility to work with the site locally and only push to the running site when you are ready to deploy your changes.</p></blockquote>
<h3>2. Create a local Git repository</h3>
<p>2.1 Download and install Git Extensions<br />
2.2 Right click the folder and click Git extensions -&gt; Browse.<br />
2.3 In the Git Explorer click Initialize Repository. Let it initialize.<br />
2.4 Click commit to make an &#8220;initial commit&#8221;. It looks into the folders and lists all non-committed files in a list (all of the files at this first commit).<br />
2.5 Click Stage All (the green double arrow) to add all files to the list of files to commit.<br />
2.6 Add a commit message for example &#8220;Initial commit&#8221;<br />
2.7 Click Commit. Now you commited all files to your local repository.</p>
<h3>3. First deploy to AppHarbor</h3>
<p>3.1 Create an account at AppHarbor<br />
3.2 Login and create an application (it&#8217;s free until you require the application to run on multiple server instances.<br />
3.3 Go to the settings page for your application and check the checkbox &#8220;Allow write-access to file system&#8221; and click update. Umbraco needs to be able to write to the file system.<br />
3.4 Go back to the start page for your application to see the &#8220;Getting started&#8221; instructions. We don&#8217;t need all the steps as we already taken care of some of them.</p>
<p>3.5 In Git Extensions browser &#8211; click &#8220;Git Bash&#8221; in the toolbar to open a command window.<br />
3.6 In the command window enter the following commands from the AppHarbor instruction page (copy paste using the context menu is easiest) to configurate your user and a necessary buffer setting (this you only need to do once for your repo) :</p>
<blockquote><p>git config &#8211;global user.name {yourname} (or use your full name)<br />
git config &#8211;global user.email {your email}<br />
git config &#8211;global http.postBuffer 52428800</p></blockquote>
<p>3.7 Now follow the last steps in the AppHarbor instructions, enter in your command window:</p>
<blockquote><p>git remote add appharbor {your appharbor repository path}<br />
git push appharbor master</p></blockquote>
<p>Git will ask you for your AppHarbor password, and then the push process will start uploading files.</p>
<p><strong>After some time (there&#8217;s quite a lot of files) you will get a message saying &#8220;Queuing build of master&#8221;. That&#8217;s good news &#8211; AppHarbor will now build the application for you and automatically deploy and host it. That is often a quick process and you will then be able to access your site &#8211; check out the url on your application page:</strong></p>
<blockquote><p>Application URL&#8217;s</p>
<p>http://myumbracosite.apphb.com</p></blockquote>
<h3>Deploying changes &#8211; this is the coolest part</h3>
<p>Now you have two copies of your Umbraco web site. One locally and one on AppHarbor. When you need to change something you&#8217;ll do that locally and then deploy the changes to AppHarbor just by using Git commit and push.</p>
<p>Let&#8217;s say you added some razor templates, css&#8217;es and javascripts and you like to deploy them.</p>
<p>4.1 Right click your local Umbraco site folder and click Git extensions &gt; Commit. The Git will find out which files you have changed and show them in the same list as you had before your first commit.<br />
4.2 Click Stage all<br />
4.3 Add a commit message &#8220;New changes to my css&#8221; and click commit. Now you committed to your local repository.</p>
<p>4.4 Go to the Git Extensions explorer and open the Git Bash window again.<br />
4.5 Write </p>
<blockquote><p>git push appharbor master</p></blockquote>
<p>enter your password when prompted.</p>
<p><strong>Git will upload the changes and AppHarbor starts a new Build process. A few moments later the updated site is live!</strong></p>
<p>(If you like to omit the database from the commit you will need to add it to the gitignore file.) </p>
<blockquote><p><strong>Commit and push from the UI &#8211; no need to open the command prompt</strong><br />Open the menuitem &#8220;Remote repositorys&#8221; in Git Ext, open the &#8220;AppHarbor&#8221; remote. Add your password to the url, so it says https://myname:mypassword@appharbor.com/mysite.git. Then go to the tab &#8220;default pull behaviour&#8221; (yeah I know, it says Pull but it goes for Push as well.) Set your AppHarbor as the default &#8220;Remote repository&#8221; click Save. Then you can use the &#8220;Commit and Push&#8221; button in the UI.</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1407&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/11/05/a-nice-deploy-approach-umbraco-5-alpha-appharbor-experimental/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>A Razor application within an Umbraco site (notes from a current project)</title>
		<link>http://joeriks.com/2011/10/27/a-razor-application-within-an-umbraco-site-notes-from-a-current-project/</link>
		<comments>http://joeriks.com/2011/10/27/a-razor-application-within-an-umbraco-site-notes-from-a-current-project/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 10:09:29 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Razor]]></category>
		<category><![CDATA[WebMatrix]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1359</guid>
		<description><![CDATA[We&#8217;re in the middle of re-developing a web application that previously was made as an asp.net Webforms app. The current requirements is to integrate the application into an Umbraco 4.7 site, to use a new design (delivered as a html, CSS &#38; js prototype) as well as to change some of the underlying database workings. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1359&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>We&#8217;re in the middle of re-developing a web application that previously was made as an asp.net Webforms app. The current requirements is to integrate the application into an Umbraco 4.7 site, to use a new design (delivered as a html, CSS &amp; js prototype) as well as to change some of the underlying database workings.</p>
<p>We decided to go for an asp.net WebPages, aka Razor, aka WebMatrix, solution in this case. It&#8217;s a very straight forward, close to the metal, way of coding for the web, and we&#8217;re very happy with our experiences so far.</strong><br />
When we develop the application we work completely outside of Umbraco, within an Asp.Net Razor website in Visual Studio (and sometimes in WebMatrix actually). The application itself is completely independent of Umbraco context.</p>
<p>So, we test run and debug our application within Visual Studio, then we deploy all changes just by FTP&#8217;ing the files to the Umbraco staging site where our customer can try it within their site. It&#8217;s a very fluent and flexible developing process.</p>
<h3>The most important parts of the application</h3>
<ul>
<li>A set of (~10) <strong>cshtmls </strong>that represents each different page (url) of the application.</li>
<li><strong>A wrapper content page </strong>in Umbraco for each of the app pages, with the path to It&#8217;s corresponding cshtml as a property, <strong>RenderScriptPath</strong>.</li>
<li><strong>A wrapper template </strong>in Umbraco, which is a copy of the standard content template for the whole site, but with one important instruction:<br />
<pre class="brush: plain;">&lt;umbraco:macro runat=&quot;server&quot; language=&quot;cshtml&quot;&gt;
@if(Model.RenderScriptPath!=&quot;&quot;) {
   @RenderPage(Model.RenderScriptPath)
}
&lt;/umbraco:macro&gt;</pre><br />
this call is rendering the actual application page within the site layout.
</li>
<li><strong>A service cshtml</strong> for serving Ajax calls<br />
<pre class="brush: plain;">@if (OurApp.CheckLogin() &amp;&amp; IsAjax)
{
  
  // routing each call to the right function / json result

  var action = Request[&quot;action&quot;];
  if (action==&quot;products&quot;) {
    var category = Request[&quot;category&quot;];
    Json.Write(OurApp.ProductsByCategory(category),Response.Output);
  }
}</pre></p>
<li>A corresponding &#8211; empty &#8211; template with just this code to render the service cshtml:<br />
<pre class="brush: plain;">&lt;umbraco:macro runat=&quot;server&quot; FileLocation=&quot;/macroscripts/ourapp/ajaxservice.cshtml&quot; /&gt;</pre></li>
<li><strong>An UmbracoMockLayout.cshtml</strong> to make the off-site app look nice, with references to the necessary CSS, images and JavaScript files</li>
<li><strong>An _PageStart.cshtml</strong> to automatically use the above layout from each of our .cshtml-pages. We do not copy the _PageStart-file to the Umbraco site (and even if we did it would not be run).<br />
<pre class="brush: plain;">@{Layout = &quot;_UmbracoMockLayout.cshtml&quot;;}</pre></li>
<li><strong>Businesslogic</strong>, in a separate project</li>
<li><a href="http://www.toptensoftware.com/petapoco/"><strong>PetaPoco</strong></a>, as the micro Orm layer for the database</li>
<li>JavaScript, CSS and image files. In the same paths in the separate project as in the Umbraco site</li>
<li><a href="http://dewd.codeplex.com/"><strong>Dewd</strong></a>, as a way for our Umbraco editors to edit some datatables directly within Umbraco</li>
</ul>
<h3>Umbraco content and asp.Net membership</h3>
<p>The application is not entirely disconnected from Umbraco (but almost). There are texts on a few of the pages that is editable from within Umbraco, and used with the common Model.Property syntax. Otherwise the application is just using the Umbraco site navigation and designs. Also the app is using the same membership as the site.</p>
<h3>Conclusion</h3>
<p>In this project we&#8217;re using techniques and products we really like and find to be very efficient and high quality. The resulting application is soon to be launced, so we cannot say much about how it ends up <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , but it&#8217;s looking good so far, and we can definitively say that the development process has been unusually friction-free and fast.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1359&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/10/27/a-razor-application-within-an-umbraco-site-notes-from-a-current-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>A playful look at WebSockets &#8211; with the help of the XSockets library</title>
		<link>http://joeriks.com/2011/10/14/a-playful-look-at-websockets-with-the-help-of-the-xsockets-library/</link>
		<comments>http://joeriks.com/2011/10/14/a-playful-look-at-websockets-with-the-help-of-the-xsockets-library/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 05:15:28 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Web frameworks]]></category>
		<category><![CDATA[WebSockets]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1294</guid>
		<description><![CDATA[What&#8217;s the best way to spend a friday night to saturday afternoon, in the city of Sundsvall, Sweden? What about coding some WebSockets together with others like minded (+ having one or two sponsored beers)? In the end of september team XSockets and XLent hosted such an event and I was happy to be able [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1294&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>What&#8217;s the best way to spend a friday night to saturday afternoon, in the city of Sundsvall, Sweden? What about coding some WebSockets together with others like minded (+ having one or two sponsored beers)? In the end of september team XSockets and XLent hosted such an event and I was happy to be able to join.</strong></p>
<p>For me it was the first real experience of WebSockets coding, and in this blog post I&#8217;ll write a few words about it (so there &#8211; my usual &#8220;I&#8217;m a noob-disclaimer&#8221;).</p>
<p><a href="http://en.wikipedia.org/wiki/WebSocket">WebSockets (and the WebSockets API)</a> is currently in an evolving phase, and as such it has varying support in the different web browsers. It&#8217;s quite a lot of work to use it directly with cross-browser support for real time applications. Therefore many look for helping libraries, actively maintained by people following the ongoing development of WebSockets and with fallback support for non-websockets-supporting browsers. <a href="http://xsockets.net/">XSockets</a> is such a library. It is under active development, has support for several WebSockets protocol versions and it has fallback support that works in most browsers, with the help of Flash or Silverlight plugins.</p>
<blockquote><p><strong>Setting up an XSockets Visual Studio solution</strong> is easy with the help of the <a href="http://nuget.org/List/Packages/XSockets">XSockets Nuget package</a>. The recommended way to start playing <a href="http://xsockets.net/Video/Index">[link to video]</a> &#8211; <a href="http://www.mathiaswestin.net/2011/10/codecamp-map-collaboration-using.html">see also this walkthrough</a> is to 1) create an empty MVC3-application, then 2) type <strong>Install-package XSockets</strong> in the package manager. The Nuget installs  a XSockets server project, a custom handler project, and a samples web project with a few samples. To have a go &#8211; 3) right click the server and run it. Then 4) open a Sample project html page also by right clicking, and browse open the file &#8211; preferrably in Chrome.</p></blockquote>
<h2>The parts of an XSockets solution</h2>
<p>For a XSockets solution to run you will need the following.</p>
<ul>
<li><strong>A websockets server</strong>. A .Net Windows command line application or a service. Configured to serve websockets communication on a specified port (for example 4502). The easiest way to get a server up and running is simply by installing the Nuget (se above).</li>
<li><strong>Client side code</strong>. For example js code using the jxsockets client side libray &#8211; best if they are running on WebSockets enabled browsers like Chrome, or Safari.</li>
</ul>
<p>The clients all communicate with the server, there&#8217;s no direct peer-to-peer communication. However, the server can of course maintain a communication between two individual clients.</p>
<h4>Here is an example of how an XSockets (and WebSockets) communication sequence can look like:</h4>
<p><strong>1. Client A creates a jXSockets instance,</strong> responsible to handle WebSockets communication with a running XSockets server.<br />
<pre class="brush: plain;">var ws = jXSockets.xWebSocket('http://myserver.com:4502/XSockets.Core.Handlers.Generic, jXSockets.WEBSOCKET);</pre></p>
<p><strong>2. The server establishes and opens the connection</strong> and the event &#8220;open&#8221; is triggered. The client can now start listen to and trigger own events.</p>
<p><pre class="brush: plain;">ws.bind(&quot;open&quot;, function() { $('#status').text('&lt;p&gt;Connection open&lt;/p&gt;');} );</pre>  </p>
<p><strong>3. Client B does the same.</strong> Now the server has two open connections. Each client is represented by a guid on serverside, and messages (as events) can easily be sent to all clients or a selection of clients.</p>
<p><strong>4. Client A triggers a &#8220;OnChatMessage&#8221; event</strong> with the data &#8220;Hello WebSockets&#8221; and &#8220;John Doe&#8221;.</p>
<p><pre class="brush: plain;">// Create a WebSocketMessage 
var myMessage = new $$.WebSocketMessage(&quot;OnChatMessage&quot;);
myMessage.AddJson({Text: &quot;Hello WebSockets&quot;,UserName:&quot;John Doe&quot;);
//  Send the message using the .trigger(WebSocketMessage) method 
ws.trigger(myMessage.PayLoad());</pre></p>
<p><strong>5. The server&#8217;s generic event handler is configured to listen to all events</strong> and broadcasts the event directly to all other clients.</p>
<p><strong>6. If Client B has a binding to the &#8220;OnChatMessage&#8221; event it will get the &#8220;Hello World!&#8221; data</strong> and can for example display it on a web page.</p>
<p><pre class="brush: plain;">// Event handler for the WebSocket event named OnChatMessage, where the WebSocket instance is named ws
ws.bind(&quot;OnChatMessage&quot;,function(message) {
 $('#message').append('&lt;p&gt;' + message.Text + ' from ' + message.UserName + '&lt;/p&gt;');
});</pre></p>
<p><strong>7. More messages is being sent between the clients and the server.</strong></p>
<p><strong>8. The connections stays open until they are actively closed.</strong> This means that the need for overhead is minimal, which in turn means it&#8217;s very efficient to send a lot of data back and forth compared to the traditional http request / response method which has a lot of overhead.</p>
<p>We can also bind to the close event if we like<br />
<pre class="brush: plain;">ws.bind(&quot;close&quot;, function() { $('#status').text('&lt;p&gt;Connection closed&lt;/p&gt;');} );</pre>  </p>
<h4>More server side</h4>
<p>The generic handler is best for demo usage, and not really (?) meant for real applications. But it&#8217;s very easy to build a custom handler which can be setup to handle the communication however you like.</p>
<h4>Hackaton</h4>
<p>A really fun part  &#8211; and the part that was given the most time &#8211; of the CodeCamp was where we participants was given the task to code real XSockets applications, which should be demo&#8217;ed at the end of the camp. It resulted in really cool apps, most of which had a entertainment/game theme, but there were also real business/industry &#8216;real-time-dashboard&#8217; like applications. </p>
<p>Here&#8217;s a short <a href="http://t.co/HsepFLj">video of my contribution</a>. <a href="http://t.co/HsepFLj"><img src="http://joeriks.files.wordpress.com/2011/10/livescore-feed-demo.png?w=630&#038;h=384" alt="" title="livescore feed demo" width="630" height="384" class="alignnone size-full wp-image-1352" /></a></p>
<p><strong>In all, the CodeCamp proved to me that WebSockets is a technique that has an important place in the modern web, and XSockets is a well engineered and easy-to-use library for WebSockets solutions.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1294&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/10/14/a-playful-look-at-websockets-with-the-help-of-the-xsockets-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/10/livescore-feed-demo.png" medium="image">
			<media:title type="html">livescore feed demo</media:title>
		</media:content>
	</item>
		<item>
		<title>Från noll till en komplett webbplats med Umbraco CMS på mindre än en timme</title>
		<link>http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/</link>
		<comments>http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 09:46:55 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Svenska]]></category>
		<category><![CDATA[WebMatrix]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1265</guid>
		<description><![CDATA[Umbraco är ett gratis opensource-CMS byggt på Microsofts ASP.NET ramverk. Det är byggt för att vara lätt att förstå och använda, samt enkelt att bygga ut. Det är ett av de 3 mest populära nedladdade programvarupaketen i Microsofts Web Platform Installer och det används över hela världen för i stort sett alla typer av webbplatser. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1265&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Umbraco är ett gratis opensource-CMS byggt på Microsofts ASP.NET ramverk. Det är byggt för att vara lätt att förstå och använda, samt enkelt att bygga ut. Det är ett av de 3 mest populära nedladdade programvarupaketen i Microsofts Web Platform Installer och det används över hela världen för i stort sett alla typer av webbplatser.</strong></p>
<p>Genom att använda gratisverktyget WebMatrix så är det väldigt smidigt att installera Umbraco på din dator &#8211; och det finns dessutom webhotell som erbjuder billig hosting för WebMatrix-sajter med mycket enkel publicering. Detta innebär att du kan ha en egen webbplats med de smidiga redigeringsmöjligheter som ett professionellt CMS erbjuder uppe och igång ute på internet på mindre än en timme. </p>
<p><strong>Tror du mig inte? Häng med&#8230;</strong></p>
<h2>1. Ladda ned och installera WebMatrix</h2>
<p>Gå till <a href="http://www.microsoft.com/web/webmatrix/">http://www.microsoft.com/web/webmatrix/</a> och installera den senaste versionen av WebMatrix.</p>
<p><a href="http://joeriks.files.wordpress.com/2011/03/webmatrix1.png"><img src="http://joeriks.files.wordpress.com/2011/03/webmatrix1.png?w=600&#038;h=300" alt="" title="webmatrix1" width="600" height="300" class="alignnone size-medium wp-image-902" /></a></p>
<h2>2. Skapa en Umbraco webbplats från WebMatrix &#8220;Web Gallery&#8221;</h2>
<p>När du startar WebMatrix får du som alternativ att starta en ny webbplats från &#8220;Web Gallery&#8221;. I galleriet hittar du Umbraco. Välj det och skriv in ett namn för din webbplats, följ sedan guiden för att ladda ned och installera Umbraco:</p>
<span style="text-align:center; display: block;"><a href="http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/"><img src="http://img.youtube.com/vi/Tvpqc6QBagU/2.jpg" alt="" /></a></span>
<h2>3. Kör Umbraco-installationen</h2>
<p>När WebMatrix har installerat Umbraco kommer du att återgå till redigeringsdelen i WebMatrix. Klicka på länken till din webbplats (site) <strong>&#8220;URL : http://localhost:nnnn&#8221;</strong> för att öppna din lokala webbplats i din webbläsare:</p>
<span style="text-align:center; display: block;"><a href="http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/"><img src="http://img.youtube.com/vi/xkAnxyp_ez0/2.jpg" alt="" /></a></span>
<p>Första gången du öppnar din lokala webbplats kommer Umbraco att köra sin installationsrutin. Där väljer du vilken typ av databas du vill använda, samt det användarnamn och lösenord du vill ha, dessutom får du om du vill välja &#8220;Starter kit&#8221; och &#8220;Skin&#8221; för din webbplats.</p>
<p>Jag rekommenderar dig att följa installationsrutinens föreslagna alternativ när sådana finns, välj således Sql CE som databas, det innebär att du inte behöver någon installerad databasserver på din dator, Sql CE använder helt enkelt en fil som kommer att sparas i din webbplats filstruktur.</p>
<p>När du får välja Starter kit och Skin föreslår jag att du väljer &#8220;Simple Starter kit&#8221;, och det Skin som du själv tycker bäst om.</p>
<h2>4. Dags för det administrativa gränssnittet i Umbraco</h2>
<p>När Umbracos installationsrutin är färdig så är det dags att titta på Umbracos användargränssnitt för första gången.</p>
<p>Lägg märke till att du har en trädvy med en &#8220;nod&#8221; för varje sida på din Umbracowebbplats. Klicka till att börja med på noden &#8220;Sample website&#8221; som representerar webbplatsens startsida. Ändra på några texter. När du har ändrat och vill att ändringarna ska synas så ska du klicka på Publicera (Publish). Då kommer din lokala sajt att uppdateras och du kan se webbplatsen med dina ändrade texter:</p>
<span style="text-align:center; display: block;"><a href="http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/"><img src="http://img.youtube.com/vi/guCUTS4A5Zc/2.jpg" alt="" /></a></span>
<p>Det är enkelt att växla fram och tillbaka mellan Umbracos användargränssnitt och din webbplats med hjälp av webbläsarens flikar. Om du tappar bort din Umbraco-flik så kan du alltid öppna den igen genom att öppna adressen http://localhost:nnn/umbraco/ (när nnn är det portnummer som WebMatrix har valt åt dig, du hittar det under Site i WebMatrix).</p>
<p>Du har nu WebMatrix och din webbplats på din egen dator och det finns ingen möjlighet att komma åt den utifrån. Webbplatsens filer finns din mapp &#8220;Mina dokument&#8221; och undermappen &#8220;My Sites&#8221;. När du har stängt WebMatrix kan du komma åt din webbplats igen genom att öppna WebMatrix och sedan välja din webbplats under &#8220;My Sites&#8221;.</p>
<h2>5. Ut med webbplatsen på internet</h2>
<p>När du har redigerat din webbplats och vill att den ska synas på internet så behöver du hitta ett webbhotell (webbhost).</p>
<p>Du kan göra det med hjälp av en länk i WebMatrix, under Publish &#8211; Find Hosting, eller använda ett webbhotell som du känner till sedan tidigare.</p>
<p>Jag testade <a href="http://www.appliedi.net/affiliates/windows-hosting.php?id=6905">&#8220;Appliedi&#8221;</a> när jag skrev den här artikeln. Deras installation var väldigt enkel med stöd för funktionen WebDeploy. Appliedi är dessutom gratis i tre månader (därefter $5 i månaden).</p>
<p><a href="http://www.appliedi.net/affiliates/windows-hosting.php?id=6905"><img src="http://joeriks.files.wordpress.com/2011/03/trywebmatrix.png?w=630" alt="" title="trywebmatrix"   class="alignnone size-full wp-image-903" /></a></p>
<p><a href="http://joeriks.files.wordpress.com/2011/03/sitecreate.png"><img src="http://joeriks.files.wordpress.com/2011/03/sitecreate.png?w=293&#038;h=300" alt="" title="sitecreate" width="293" height="300" class="alignnone size-medium wp-image-904" /></a></p>
<p>När du har beställt testpaketet ska du få ett epostmeddelande med dina inloggningsuppgifter.</p>
<p><a href="http://joeriks.files.wordpress.com/2011/03/webdeploysettings.png"><img src="http://joeriks.files.wordpress.com/2011/03/webdeploysettings.png?w=300&#038;h=136" alt="" title="webdeploysettings" width="300" height="136" class="alignnone size-medium wp-image-905" /></a></p>
<p>Kopiera dessa uppgifter och klistra in dem i WebMatrix &#8220;Publish Settings&#8221;</p>
<p><a href="http://joeriks.files.wordpress.com/2011/03/publishsettings.png"><img src="http://joeriks.files.wordpress.com/2011/03/publishsettings.png?w=600&#038;h=430" alt="" title="publishsettings" width="600" height="430" class="alignnone size-medium wp-image-906" /></a></p>
<h2>6. Publicera!</h2>
<p>När du har lagt in dessa uppgifter så kan du publicera din webbplats, klicka på &#8220;Publish&#8221;. Det kommer att ta några minuter eftersom en fullständig Umbracoinstallation innehåller ganska många filer. När publiceringen är klar kommer du &#8211; och alla andra &#8211; att komma åt din sida på Internet!</p>
<p><a href="http://joeriks.files.wordpress.com/2011/03/the-live-site.png"><img src="http://joeriks.files.wordpress.com/2011/03/the-live-site.png?w=600&#038;h=440" alt="" title="the live site" width="600" height="440" class="alignnone size-medium wp-image-907" /></a></p>
<h2>Att redigera innehållet</h2>
<p>Både din lokala installation och den på ditt webbhotell har allting som behövs både för att visa webbplatsen och för att redigera den med Umbracos administrativa gränssnitt. Förutom publiceringsrutinen så finns det ingenting som kopplar ihop din lokala installation med den som finns på Internet. Det innebär att om du ändrar innehåll lokalt så kommer det inte att synas utåt om du inte publicerar om webbplatsen. Men det innebär också att du kan använda din lokala kopia för att testa olika idéer, och sedan lägga in dem på din publika webbplats när du är nöjd med resultatet, helt enkelt genom att jobba i det administrativa gränssnittet där också.</p>
<p>På samma sätt som att din lokala kopia är åtkomlig via localhost://nnn/umbraco/ så kommer du åt din webbplats på internet genom att gå till adressen http://www.mysite.com/umbraco/ . Inloggningsuppgifterna är desamma som du valde när du gjorde umbracoinstallationen.</p>
<h2>Lycka till!</h2>
<p>Läs mer om Umbraco på <a href="http://www.umbraco.org">http://www.umbraco.org</a> och om du har frågor eller kommentarer så får du gärna ställa dem här. Om det finns intresse så kommer jag återkomma med fler artiklar på svenska om Umbraco.</p>
<p>Jag kan också varmt rekommendera <a href="http://our.umbraco.org">Umbraco-forumet</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1265/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1265&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/08/08/fran-noll-till-en-komplett-webbplats-med-umbraco-cms-pa-mindre-an-en-timme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/webmatrix1.png?w=600" medium="image">
			<media:title type="html">webmatrix1</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/trywebmatrix.png" medium="image">
			<media:title type="html">trywebmatrix</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/sitecreate.png?w=293" medium="image">
			<media:title type="html">sitecreate</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/webdeploysettings.png?w=300" medium="image">
			<media:title type="html">webdeploysettings</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/publishsettings.png?w=600" medium="image">
			<media:title type="html">publishsettings</media:title>
		</media:content>

		<media:content url="http://joeriks.files.wordpress.com/2011/03/the-live-site.png?w=600" medium="image">
			<media:title type="html">the live site</media:title>
		</media:content>
	</item>
		<item>
		<title>Playing with EntityFramework Code First and &#8220;migrations&#8221; [5 minutes]</title>
		<link>http://joeriks.com/2011/08/01/playing-with-entityframework-code-first-and-migrations-5-minutes/</link>
		<comments>http://joeriks.com/2011/08/01/playing-with-entityframework-code-first-and-migrations-5-minutes/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 20:20:01 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[AspNet]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1236</guid>
		<description><![CDATA[When EF 4 with CodeFirst came I was disappointed with the lack of automatic schema updates. Now a first version of &#8220;migrations&#8221; has arrived, which made me re-look at EF CodeFirst and make a small experiment &#8211; I was in a hurry and pretty sloppy, not reading anything more than briefly on this Scott Hanselman [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1236&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>When EF 4 with CodeFirst came I was disappointed with the lack of automatic schema updates. Now a first version of &#8220;migrations&#8221; has arrived, which made me re-look at EF CodeFirst and make a small experiment &#8211; I was in a hurry and pretty sloppy, not reading anything more than briefly on this <a href="http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx">Scott Hanselman post</a>. And I was pretty certain I was going to fail on at least one point in my experiment. But as it turned out it worked fine all the way.</strong></p>
<p>This is what I did:</p>
<ul>
<li>Create a new Console Application in Visual Studio</li>
<li>Add the EF Migrations Nuget (which also includes EF itself).<br />
<pre class="brush: plain;">PM&gt; Install-Package EntityFramework.SqlMigrations</pre></li>
<li>Add these classes:<br />
<pre class="brush: plain;">public class Person
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string SurName { get; set; }

}
public class DemoContext : DbContext
{
    public DbSet&lt;Person&gt; People { get; set; }
}</pre></li>
<li>Make Main add some people:<br />
<pre class="brush: plain;">static void Main(string[] args)
{
    var db = new DemoContext();
    db.People.Add(new Person { Name = &quot;Test 1&quot;});
    db.People.Add(new Person { Name = &quot;Test 2&quot;});
    db.SaveChanges();
}</pre></li>
<li>Run the program.</li>
</ul>
<h4>What happened here?</h4>
<p>For me all went fine &#8211; no errors. Which meant the program either failed silently or I got a new database somewhere. I looked for an automatically created SQL CE DB file in my project folder, but none could be found. However I found a new DB in my <strong>SqlExpress</strong> instance, named <strong>ConsoleApplication1.DemoContext</strong>. Obviously it&#8217;s the convention for EF to create such and populate it with the necessary data. And yes, the table People was there with two records, Test 1 and Test 2. Very cool.</p>
<h3>How about changing the schema a bit?</h3>
<p>Now for some testing of the migrations part of this experiment.</p>
<ul>
<li>Add the property Surname<br />
<pre class="brush: plain;">public class Person
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
}</pre></li>
<li>And some code in Main<br />
<pre class="brush: plain;">static void Main(string[] args)
{
    var db = new DemoContext();
    db.People.Add(new Person { Name = &quot;Test 3&quot;, Surname = &quot;AAA&quot; });
    db.People.Add(new Person { Name = &quot;Test 4&quot;, Surname = &quot;BBB&quot; });
    db.SaveChanges();
}</pre></li>
<li>When I run this I got an expected error &#8211; because the newly added property does not have a corresponding field in the database table. Time to let the EF Migration perform it&#8217;s magic:<br />
<pre class="brush: plain;">PM&gt; Update-Database</pre></li>
<li>EF migrations takes some time to complete, when it&#8217;s done the schema is updated and the program runs fine. And the previously added names are still in the database.</li>
</ul>
<p>I think EF SqlMigrations looks really nice. I&#8217;m sure it does not cover all and everything, but I can think of quite a few of my previous coding projects where I would have been in great benefit of this tool.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1236/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1236&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/08/01/playing-with-entityframework-code-first-and-migrations-5-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>Making the MVC3 Model independent of data source (using Ninject) [beginners]</title>
		<link>http://joeriks.com/2011/07/25/making-the-mvc3-model-independent-of-data-source-using-ninject-beginners/</link>
		<comments>http://joeriks.com/2011/07/25/making-the-mvc3-model-independent-of-data-source-using-ninject-beginners/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 15:59:43 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[AspNet]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Looking for a great Web App platform]]></category>
		<category><![CDATA[MVC3]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1205</guid>
		<description><![CDATA[Here are three &#8220;rules&#8221; I try to adopt to in my relearning MVC3 app: The Views should not do anything else than display the data. The Controllers should (on get&#8217;s) only be responsible for serving the right viewmodel to the right view for the particular request. The Models should not depend on one particular source [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1205&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Here are three &#8220;rules&#8221; I try to adopt to in my relearning MVC3 app:</strong></p>
<ul>
<li>The <strong>Views</strong> should not do anything else than display the data.</li>
<li>The <strong>Controllers</strong> should (on get&#8217;s) only be responsible for serving the right viewmodel to the right view for the particular request.</li>
<li>The <strong>Models</strong> should not depend on one particular source of data.</li>
</ul>
<p>In my <a href="http://joeriks.wordpress.com/2011/07/25/adding-a-razor-view-to-our-hello-world-mvc3-app-beginners/" title="Adding a Razor View to our Hello World MVC3-app [beginners]">last post</a> I made a small controller that constructed a mock viewmodel and sent it to the View. Now I like to use a separate mock data class to serve that purpose. The controller should take the id from the Url, get the data from the data class and serve it to the view. </p>
<p>Other than that I like to be able to change from my mock data to a real database, back and forth. I accomplish that with the help of an interface for the datacontext and the use of a dependency injection framework for the actual coupling. I am new to DI and use <strong>Ninject</strong> (install-package Ninject) as I heard it&#8217;s easy to use.</p>
<p><pre class="brush: plain;">using System;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject;

namespace MyApplication
{
    public interface IDataLayer
    {
        dynamic GetItem(int id);
        dynamic SaveItem(dynamic item);
    }

    public class MockDataLayer : IDataLayer
    {
        public dynamic GetItem(int id)
        {
            dynamic item = new System.Dynamic.ExpandoObject();
            item.Id = id;
            item.Name = &quot;Some name&quot;;
            return item;
        }
        public dynamic SaveItem(dynamic item)
        {
            return item;
        }
    }
    public class ItemController : Controller
    {
        public ActionResult Display(int id = 0)
        {
            dynamic viewModel = MvcApplication.DataContext.GetItem(id);
            return View(viewModel);
        }
    }
    public class MvcApplication : System.Web.HttpApplication
    {
        public static IDataLayer DataContext;

        protected void Application_Start(object sender, EventArgs e)
        {
            // the following three rows is the Ninject use
            IKernel kernel = new StandardKernel();

            kernel.Bind&lt;IDataLayer&gt;().To&lt;MockDataLayer&gt;();
            DataContext = kernel.Get&lt;IDataLayer&gt;();

            RouteTable.Routes.MapRoute(&quot;&quot;, &quot;{id}&quot;, new { controller = &quot;Item&quot;, action = &quot;Display&quot;, id = UrlParameter.Optional });
        }
    }
}</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1205/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1205&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/07/25/making-the-mvc3-model-independent-of-data-source-using-ninject-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding a Razor View to our Hello World MVC3-app [beginners]</title>
		<link>http://joeriks.com/2011/07/25/adding-a-razor-view-to-our-hello-world-mvc3-app-beginners/</link>
		<comments>http://joeriks.com/2011/07/25/adding-a-razor-view-to-our-hello-world-mvc3-app-beginners/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 15:58:30 +0000</pubDate>
		<dc:creator>joeriks</dc:creator>
				<category><![CDATA[AspNet]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Looking for a great Web App platform]]></category>
		<category><![CDATA[MVC3]]></category>

		<guid isPermaLink="false">http://joeriks.wordpress.com/?p=1181</guid>
		<description><![CDATA[In my previous post I made an example of how to write a very light weight MVC3 app with only one file (well, besides the web.config and global.asax). In this post I&#8217;ll add a Razor view as simply as possible. The Razor view file requires us to add a little bit of structure to our [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1181&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>In my <a href="http://joeriks.wordpress.com/2011/07/22/the-r-in-mvc3-or-how-to-create-a-one-file-mvc3-app-beginners/" title="“The R in MVC3″ or “how to create a one file MVC3-app” [beginners]">previous post</a> I made an example of how to write a very light weight MVC3 app with only one file (well, besides the web.config and global.asax). In this post I&#8217;ll add a Razor view as simply as possible.</strong></p>
<p>The Razor view file requires us to add a little bit of structure to our project, namely a root Views folder, a web.config file and a separate folder for the views of each of our controllers:</p>
<p><pre class="brush: plain;">/Views (folder in the root)
/Views/web.config (config file with the configuration for the view engine)
/Views/Item/ (the folder for our controller)</pre></p>
<p>In the <strong>/Views/Item</strong> folder we&#8217;re going to add our razor file, <strong>Display.cshtml.</strong> To use that file we&#8217;re adding a controller with an action function. This function can consist of only the instruction <strong>return View()</strong> if we like. With that MVC3 automatically looks for and runs the view file in the following path <strong>/Views/{controllername}/{actionname}.cshtml</strong>.</p>
<p>However, I like to add a little bit of code to show how a viewmodel (a data object) typically is being sent to and used by a view.</p>
<p><pre class="brush: plain;">using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcApplication3
{
    public class ItemController : Controller
    {
        public ActionResult Display(int id = 0)
        {
            dynamic viewModel = new System.Dynamic.ExpandoObject(); // we add a view model with some data
            viewModel.Id = id;
            viewModel.Name = &quot;Some name&quot;;
            return View(viewModel); 
        }
    }
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapRoute(&quot;&quot;, &quot;item/display/{id}&quot;, new { controller = &quot;Item&quot;, action = &quot;Display&quot;, id = UrlParameter.Optional });
        }
    }
}</pre></p>
<p>With this model, we can write our razor view as such:<br />
<pre class="brush: plain;">@model dynamic // defines the type of the view model (not required)
&lt;h2&gt;Hello World&lt;/h2&gt;

id: @Model.Id // using the data from the view model with the @ razor syntax
name: @Model.Name
</pre></p>
<p>The mentioned /Views/web.config file is essential for MVC3 for the Razor view engine to function properly. The one I use is simply the one that comes with a empty MVC3 project and I don&#8217;t find it necessary to paste it here.</p>
<h3>The heart of a web application</h3>
<p>This is pretty much what I need as a base for my web applications. From here it&#8217;s straight forward to build Html with the help of Razor helpers and templates, and construct models with the help of good ol&#8217; C# businesslogic and a data access library of choice.</p>
<p><i>Oh, and <a href="http://joeriks.wordpress.com/2011/07/25/making-the-mvc3-model-independent-of-data-source-using-ninject-beginners/" title="Making the MVC3 Model independent of data source (using Ninject) [beginners]">dependency injection</a>, source code versioning, deployments and testing&#8230;</i></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/joeriks.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/joeriks.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/joeriks.wordpress.com/1181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=joeriks.com&amp;blog=11388728&amp;post=1181&amp;subd=joeriks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://joeriks.com/2011/07/25/adding-a-razor-view-to-our-hello-world-mvc3-app-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c1ed377a5b2e96c567e4184a7be70b1?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">joeriks</media:title>
		</media:content>
	</item>
	</channel>
</rss>
