<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Web Developer</title>
		<link>http://blogs.lessthandot.com/index.php/WebDev/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>There are now Visual studio project templates for Nancy</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/there-are-now-visual-studio</link>
			<pubDate>Wed, 01 May 2013 11:11:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2189@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;We all know and love &lt;a href=&quot;http://nancyfx.org&quot;&gt;Nancy &lt;/a&gt;by now. I love it anyway.&lt;/p&gt;

&lt;p&gt;Up until now you needed to create an empty ASP.Net project and go from there. &lt;/p&gt;

&lt;p&gt;But now you there are templates to make it easier for you to start a new Nancy project.&lt;/p&gt;

&lt;p&gt;For now only C#.&lt;/p&gt;

&lt;p&gt;You will have to download the vsix from the &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/f1e29f61-4dff-4b1e-a14b-6bd0d307611a/&quot;&gt;visual studio gallery&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The restart your VS if it was open.&lt;/p&gt;

&lt;p&gt;If you know try to create a new project you will see this list in the web category.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates1.png?mtime=1367406283&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates1.png?mtime=1367406283&quot; width=&quot;955&quot; height=&quot;660&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Here I created a Nancy project with ASP.Net hosting and Razor. &lt;/p&gt;

&lt;p&gt;Here are the files it creates.&lt;/p&gt;
&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates2.png?mtime=1367406551&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates2.png?mtime=1367406551&quot; width=&quot;274&quot; height=&quot;435&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;And here is the module it creates.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates3.png?mtime=1367406566&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates3.png?mtime=1367406566&quot; width=&quot;333&quot; height=&quot;247&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;I&#039;ll leave it a surprise for you to discover what is in the other files and project. But needless to say I like.&lt;/p&gt;

&lt;p&gt;Thanks to the whole Nancy team for all the hard work.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/there-are-now-visual-studio&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>We all know and love <a href="http://nancyfx.org">Nancy </a>by now. I love it anyway.</p>

<p>Up until now you needed to create an empty ASP.Net project and go from there. </p>

<p>But now you there are templates to make it easier for you to start a new Nancy project.</p>

<p>For now only C#.</p>

<p>You will have to download the vsix from the <a href="http://visualstudiogallery.msdn.microsoft.com/f1e29f61-4dff-4b1e-a14b-6bd0d307611a/">visual studio gallery</a>.</p>

<p>The restart your VS if it was open.</p>

<p>If you know try to create a new project you will see this list in the web category.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates1.png?mtime=1367406283"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates1.png?mtime=1367406283" width="955" height="660" /></a></div>

<p>Here I created a Nancy project with ASP.Net hosting and Razor. </p>

<p>Here are the files it creates.</p>
<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates2.png?mtime=1367406551"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates2.png?mtime=1367406551" width="274" height="435" /></a></div>

<p>And here is the module it creates.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates3.png?mtime=1367406566"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancytemplates3.png?mtime=1367406566" width="333" height="247" /></a></div>

<p>I'll leave it a surprise for you to discover what is in the other files and project. But needless to say I like.</p>

<p>Thanks to the whole Nancy team for all the hard work.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/there-are-now-visual-studio">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/there-are-now-visual-studio#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2189</wfw:commentRss>
		</item>
				<item>
			<title>Trying out Gibraltar's Loupe with Nancy</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/trying-out-gibraltar-s-loupe</link>
			<pubDate>Sat, 23 Mar 2013 03:55:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2162@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;I downloaded and tested Gibraltar&#039;s Loupe today and tried to find out what it could add to my application. And because Rachel Hawley asked me t review it, and who am I to refuse her anything.&lt;/p&gt;

&lt;p&gt;I already add as much logging to my application as possible because it makes it a lot easier to find bugs and fix them once you go into productions. &lt;/p&gt;

&lt;p&gt;But log files can get overwhelming sometimes.&lt;/p&gt;

&lt;p&gt;This is where Gibraltar analyst can help. &lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;I downloaded the 3.0 preview 3. Installation is easy and for now I only installed the desktopversion, but there is also a webversion.&lt;/p&gt;

&lt;p&gt;I created a small nancy application with the razor viewengine.&lt;/p&gt;

&lt;p&gt;With this as my view.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb78908&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/html.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&lt;/span&gt;&lt;/a&gt; xmlns=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/head.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/title.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/body.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/p.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Welcome to OUR world!&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb86625&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and this as my module.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb76264&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports Nancy&lt;br /&gt;Imports Gibraltar.&lt;span style=&quot;color: #000000;&quot;&gt;Agent&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; MainModule&lt;br /&gt;&amp;nbsp; &amp;nbsp; Inherits NancyModule&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;MyBase&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;parameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return View&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Main&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb65080&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I saved all of it and then went into the loupe desktop.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe1.png?mtime=1364009122&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe1.png?mtime=1364009122&quot; width=&quot;1032&quot; height=&quot;652&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;YOu can now click the big green button that says Add Gribraltar now, point it to your project give it a name and whatnot and voila Gibraltar is there.&lt;/p&gt;

&lt;h2&gt;Logging&lt;/h2&gt;

&lt;p&gt;When I run it and go to live sessions.&lt;br /&gt;
I can see it. &lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe3.png?mtime=1364009498&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe3.png?mtime=1364009498&quot; width=&quot;1032&quot; height=&quot;652&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;No idea why it is there twice but you can click one of them.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe2.png?mtime=1364009376&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe2.png?mtime=1364009376&quot; width=&quot;991&quot; height=&quot;524&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;That&#039;s already more information than we are used to, and we have yet to add logging.&lt;/p&gt;

&lt;p&gt;We can do this by using the Gibraltar Agent logging (but we don&#039;t have to).&lt;/p&gt;

&lt;p&gt;Just add a line like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb33449&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;MyBase&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;parameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Log.&lt;span style=&quot;color: #000000;&quot;&gt;TraceInformation&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Opening mainmodule&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return View&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Main&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb8630&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And next time you run this.&lt;/p&gt;

&lt;p&gt;you will see this in your logging session.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe4.png?mtime=1364009881&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe4.png?mtime=1364009881&quot; width=&quot;1101&quot; height=&quot;187&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;You can even click on that link and go to your code.&lt;/p&gt;

&lt;p&gt;Or see the code in the tab mainmodule.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe5.png?mtime=1364010034&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe5.png?mtime=1364010034&quot; width=&quot;652&quot; height=&quot;249&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;That is simple enough.&lt;/p&gt;

&lt;h2&gt;Exceptions&lt;/h2&gt;

&lt;p&gt;So how do we deal with exceptions and unhandled exceptions?&lt;/p&gt;

&lt;p&gt;Let&#039;s add this code to our module.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb59084&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;MyBase&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;/test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;parameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Try&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Throw&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Exception&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;some message loup should pick up&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Catch ex &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Exception&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Log.&lt;span style=&quot;color: #000000;&quot;&gt;TraceError&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ex, &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;something&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return View&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Main&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Try&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;MyBase&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;/test2&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;parameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0600FF;&quot;&gt;Throw&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Exception&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;some message loup should pick up&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb71775&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If I now go to the page /test I will see this.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe6.png?mtime=1364010367&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe6.png?mtime=1364010367&quot; width=&quot;813&quot; height=&quot;199&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;The exception is nicely logged.&lt;/p&gt;

&lt;p&gt;But if I go to page /test2, I see nothing.&lt;/p&gt;

&lt;p&gt;Gibraltar does not log unhandled exception automatically. We either need ELMAH or we need to add logging to an event somewhere.&lt;/p&gt;

&lt;p&gt;Luckily in Nancy this is easy.&lt;/p&gt;

&lt;p&gt;Just add a class that implements IErrorhandler and Nancy will do the rest.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb25937&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports Nancy&lt;br /&gt;Imports Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;ErrorHandling&lt;/span&gt;&lt;br /&gt;Imports Gibraltar.&lt;span style=&quot;color: #000000;&quot;&gt;Agent&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; Errorhandler&lt;br /&gt;&amp;nbsp; &amp;nbsp; Implements IErrorHandler&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; HandlesStatusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, &lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean Implements IStatusCodeHandler.&lt;span style=&quot;color: #000000;&quot;&gt;HandlesStatusCode&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return statusCode = HttpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;InternalServerError&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; Handle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, &lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; Implements IStatusCodeHandler.&lt;span style=&quot;color: #000000;&quot;&gt;Handle&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; errorObject &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Object&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.&lt;span style=&quot;color: #000000;&quot;&gt;Items&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;TryGetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;NancyEngine.&lt;span style=&quot;color: #000000;&quot;&gt;ERROR_EXCEPTION&lt;/span&gt;, errorObject&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; ex = CType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errorObject, Exception&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Log.&lt;span style=&quot;color: #000000;&quot;&gt;TraceError&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ex, &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;unhandled exception&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb53786&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And now we will see our exception.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe7.png?mtime=1364010747&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe7.png?mtime=1364010747&quot; width=&quot;798&quot; height=&quot;286&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Loupe was pretty easy to setup and get going. Loupe does however come at a price. Is that price to high? That depends on the value you place on your business.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/trying-out-gibraltar-s-loupe&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>I downloaded and tested Gibraltar's Loupe today and tried to find out what it could add to my application. And because Rachel Hawley asked me t review it, and who am I to refuse her anything.</p>

<p>I already add as much logging to my application as possible because it makes it a lot easier to find bugs and fix them once you go into productions. </p>

<p>But log files can get overwhelming sometimes.</p>

<p>This is where Gibraltar analyst can help. </p>

<h2>Installation</h2>

<p>I downloaded the 3.0 preview 3. Installation is easy and for now I only installed the desktopversion, but there is also a webversion.</p>

<p>I created a small nancy application with the razor viewengine.</p>

<p>With this as my view.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb99162'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb99162','cb18429'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb99162" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></a></span>Welcome to OUR world!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></li></ol></div><div id="cb18429" style="display: none; color: red;"></div></div></div>

<p>and this as my module.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb67861'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb67861','cb42207'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb67861" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports Nancy</li><li style="" class="li2">Imports Gibraltar.<span style="color: #000000;">Agent</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> MainModule</li><li style="" class="li1">&nbsp; &nbsp; Inherits NancyModule</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> <span style="color: #0600FF;">New</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">MyBase</span>.<span style="color: #0600FF;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;/&quot;</span><span style="color: #000000;">&#41;</span> = <span style="color: #0600FF;">Function</span><span style="color: #000000;">&#40;</span>parameters<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return View<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Main&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb42207" style="display: none; color: red;"></div></div></div>

<p>I saved all of it and then went into the loupe desktop.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe1.png?mtime=1364009122"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe1.png?mtime=1364009122" width="1032" height="652" /></a></div>

<p>YOu can now click the big green button that says Add Gribraltar now, point it to your project give it a name and whatnot and voila Gibraltar is there.</p>

<h2>Logging</h2>

<p>When I run it and go to live sessions.<br />
I can see it. </p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe3.png?mtime=1364009498"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe3.png?mtime=1364009498" width="1032" height="652" /></a></div>

<p>No idea why it is there twice but you can click one of them.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe2.png?mtime=1364009376"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe2.png?mtime=1364009376" width="991" height="524" /></a></div>

<p>That's already more information than we are used to, and we have yet to add logging.</p>

<p>We can do this by using the Gibraltar Agent logging (but we don't have to).</p>

<p>Just add a line like this.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb79991'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb79991','cb61203'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb79991" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">MyBase</span>.<span style="color: #0600FF;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;/&quot;</span><span style="color: #000000;">&#41;</span> = <span style="color: #0600FF;">Function</span><span style="color: #000000;">&#40;</span>parameters<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #000000;">TraceInformation</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Opening mainmodule&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return View<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Main&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li></ol></div><div id="cb61203" style="display: none; color: red;"></div></div></div>

<p>And next time you run this.</p>

<p>you will see this in your logging session.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe4.png?mtime=1364009881"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe4.png?mtime=1364009881" width="1101" height="187" /></a></div>

<p>You can even click on that link and go to your code.</p>

<p>Or see the code in the tab mainmodule.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe5.png?mtime=1364010034"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe5.png?mtime=1364010034" width="652" height="249" /></a></div>

<p>That is simple enough.</p>

<h2>Exceptions</h2>

<p>So how do we deal with exceptions and unhandled exceptions?</p>

<p>Let's add this code to our module.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb93291'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb93291','cb68456'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb93291" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">MyBase</span>.<span style="color: #0600FF;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;/test&quot;</span><span style="color: #000000;">&#41;</span> = <span style="color: #0600FF;">Function</span><span style="color: #000000;">&#40;</span>parameters<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Try</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Throw</span> <span style="color: #0600FF;">New</span> Exception<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;some message loup should pick up&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Catch ex <span style="color: #0600FF;">As</span> Exception</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #000000;">TraceError</span><span style="color: #000000;">&#40;</span>ex, <span style="color: #0600FF;">&quot;something&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return View<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Main&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Try</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">MyBase</span>.<span style="color: #0600FF;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;/test2&quot;</span><span style="color: #000000;">&#41;</span> = <span style="color: #0600FF;">Function</span><span style="color: #000000;">&#40;</span>parameters<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">Throw</span> <span style="color: #0600FF;">New</span> Exception<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;some message loup should pick up&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li></ol></div><div id="cb68456" style="display: none; color: red;"></div></div></div>

<p>If I now go to the page /test I will see this.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe6.png?mtime=1364010367"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe6.png?mtime=1364010367" width="813" height="199" /></a></div>

<p>The exception is nicely logged.</p>

<p>But if I go to page /test2, I see nothing.</p>

<p>Gibraltar does not log unhandled exception automatically. We either need ELMAH or we need to add logging to an event somewhere.</p>

<p>Luckily in Nancy this is easy.</p>

<p>Just add a class that implements IErrorhandler and Nancy will do the rest.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb35193'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb35193','cb72180'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb35193" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports Nancy</li><li style="" class="li2">Imports Nancy.<span style="color: #000000;">ErrorHandling</span></li><li style="" class="li1">Imports Gibraltar.<span style="color: #000000;">Agent</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> Errorhandler</li><li style="" class="li2">&nbsp; &nbsp; Implements IErrorHandler</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Function</span> HandlesStatusCode<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, <span style="color: #0600FF;">ByVal</span> context <span style="color: #0600FF;">As</span> NancyContext<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> Boolean Implements IStatusCodeHandler.<span style="color: #000000;">HandlesStatusCode</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Return statusCode = HttpStatusCode.<span style="color: #000000;">InternalServerError</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> Handle<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, <span style="color: #0600FF;">ByVal</span> context <span style="color: #0600FF;">As</span> NancyContext<span style="color: #000000;">&#41;</span> Implements IStatusCodeHandler.<span style="color: #000000;">Handle</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> errorObject <span style="color: #0600FF;">As</span> Object</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #000000;">Items</span>.<span style="color: #000000;">TryGetValue</span><span style="color: #000000;">&#40;</span>NancyEngine.<span style="color: #000000;">ERROR_EXCEPTION</span>, errorObject<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> ex = CType<span style="color: #000000;">&#40;</span>errorObject, Exception<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #000000;">TraceError</span><span style="color: #000000;">&#40;</span>ex, <span style="color: #0600FF;">&quot;unhandled exception&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb72180" style="display: none; color: red;"></div></div></div>

<p>And now we will see our exception.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe7.png?mtime=1364010747"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/Loupe/loupe7.png?mtime=1364010747" width="798" height="286" /></a></div>

<h2>Conclusion</h2>

<p>Loupe was pretty easy to setup and get going. Loupe does however come at a price. Is that price to high? That depends on the value you place on your business.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/trying-out-gibraltar-s-loupe">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/trying-out-gibraltar-s-loupe#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2162</wfw:commentRss>
		</item>
				<item>
			<title>Crazy stuff I do with Nancy</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/crazy-stuff-i-do-with</link>
			<pubDate>Fri, 15 Mar 2013 12:58:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2146@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;No, not that.&lt;/p&gt;

&lt;p&gt;I had the need to write documentation for my services. I thought having them as html would be nice and good enough. &lt;/p&gt;

&lt;p&gt;So I made a bunch of vbhtml razorviews because I want my pages to be pretty and use the masterpage I already made for my main site. You know, to be consistent. &lt;/p&gt;

&lt;p&gt;So I had this.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;page1.vbhtml&lt;/li&gt;
  &lt;li&gt;page2.vbhtml&lt;/li&gt;
  &lt;li&gt;page3.vbhtml&lt;/li&gt;
  &lt;li&gt;page4.vbhtml&lt;/li&gt;
  &lt;li&gt;index.vbhtml&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And to show those pages I just have this in my module.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb76929&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;MyBase.Get(&amp;quot;/{Title}&amp;quot;) = Function(parameters)&lt;br /&gt;&amp;nbsp; Return Negotiate.WithView(&amp;quot;documentation/&amp;quot; &amp;amp; parameters.Title)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb54542&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So calling page1 is as easy as &lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;codespan&quot;&gt;/documentation/page1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But what if someone did&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;codespan&quot;&gt;/documentation/page12&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;They would get an error.&lt;/p&gt;

&lt;p&gt;But, meh, I don&#039;t want that. I want them to return to the index instead. &lt;/p&gt;

&lt;p&gt;So here is my solution.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb11827&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Public Sub New(viewlocator As IViewLocator)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyBase.New(&amp;quot;/documentation&amp;quot;)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyBase.Get(&amp;quot;/{Title}&amp;quot;) = Function(parameters)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If viewlocator.LocateView(&amp;quot;documentation/&amp;quot; &amp;amp; parameters.Title, Context) IsNot Nothing Then&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Return Negotiate.WithView(&amp;quot;documentation/&amp;quot; &amp;amp; parameters.Title)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Else&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Return Negotiate.WithView(&amp;quot;documentation/index&amp;quot;)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Function&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb61441&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With help from GrumpyDev.&lt;/p&gt;

&lt;p&gt;Quick and easy. &lt;/p&gt;

&lt;p&gt;I do not want to put to much work in the documentation since noone will ever read it anyway.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/crazy-stuff-i-do-with&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>No, not that.</p>

<p>I had the need to write documentation for my services. I thought having them as html would be nice and good enough. </p>

<p>So I made a bunch of vbhtml razorviews because I want my pages to be pretty and use the masterpage I already made for my main site. You know, to be consistent. </p>

<p>So I had this.</p>

<ul>
  <li>page1.vbhtml</li>
  <li>page2.vbhtml</li>
  <li>page3.vbhtml</li>
  <li>page4.vbhtml</li>
  <li>index.vbhtml</li>
</ul>

<p>And to show those pages I just have this in my module.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb3087'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb3087','cb92119'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb3087" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">MyBase.Get(&quot;/{Title}&quot;) = Function(parameters)</li><li style="" class="li2">&nbsp; Return Negotiate.WithView(&quot;documentation/&quot; &amp; parameters.Title)</li><li style="" class="li1">End If</li></ol></div><div id="cb92119" style="display: none; color: red;"></div></div></div>

<p>So calling page1 is as easy as </p>

<p><code class="codespan">/documentation/page1</code></p>

<p>But what if someone did</p>

<p><code class="codespan">/documentation/page12</code></p>

<p>They would get an error.</p>

<p>But, meh, I don't want that. I want them to return to the index instead. </p>

<p>So here is my solution.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb20258'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb20258','cb7553'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb20258" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Public Sub New(viewlocator As IViewLocator)</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyBase.New(&quot;/documentation&quot;)</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyBase.Get(&quot;/{Title}&quot;) = Function(parameters)</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If viewlocator.LocateView(&quot;documentation/&quot; &amp; parameters.Title, Context) IsNot Nothing Then</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Negotiate.WithView(&quot;documentation/&quot; &amp; parameters.Title)</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Else</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Negotiate.WithView(&quot;documentation/index&quot;)</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End Function</li></ol></div><div id="cb7553" style="display: none; color: red;"></div></div></div>

<p>With help from GrumpyDev.</p>

<p>Quick and easy. </p>

<p>I do not want to put to much work in the documentation since noone will ever read it anyway.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/crazy-stuff-i-do-with">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/crazy-stuff-i-do-with#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2146</wfw:commentRss>
		</item>
				<item>
			<title>Nancy, IIS 7 and the PUT command</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-iis-7-and-the</link>
			<pubDate>Wed, 13 Mar 2013 06:49:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2142@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;When you use PUT in your Nancy application and you host your application on an IIS 7 server then you might get a 405 error (Method not allowed).&lt;/p&gt;

&lt;p&gt;The solution to this problem is very simple but I will put it here for me.&lt;/p&gt;

&lt;p&gt;The problem is that you might have the webdavmodule installed on your IIS and that is gobbling up all the PUT requests. &lt;/p&gt;

&lt;p&gt;So the simple solution is to remove the webdavmodule.&lt;/p&gt;

&lt;p&gt;You can do this via the IIS manager and just remove it from your site, but if you use webdeploy it will add it back in the next time you deploy. &lt;/p&gt;

&lt;p&gt;So it is better to use the webconfig to tell IIS you really don&#039;t want it for your particular site.&lt;/p&gt;

&lt;p&gt;So you add this to the web.config&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb81490&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;system&lt;/span&gt;.webServer&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;modules&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;remove&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;WebDAVModule&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/modules&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/system&lt;/span&gt;.webServer&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb61470&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple, and it works. Let&#039;s move on.&lt;/p&gt;

&lt;p&gt;No TDD was involved in the making of this blogpost.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-iis-7-and-the&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>When you use PUT in your Nancy application and you host your application on an IIS 7 server then you might get a 405 error (Method not allowed).</p>

<p>The solution to this problem is very simple but I will put it here for me.</p>

<p>The problem is that you might have the webdavmodule installed on your IIS and that is gobbling up all the PUT requests. </p>

<p>So the simple solution is to remove the webdavmodule.</p>

<p>You can do this via the IIS manager and just remove it from your site, but if you use webdeploy it will add it back in the next time you deploy. </p>

<p>So it is better to use the webconfig to tell IIS you really don't want it for your particular site.</p>

<p>So you add this to the web.config</p>

<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb81765'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb81765','cb56016'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb81765" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;system</span>.webServer<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;modules<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;WebDAVModule&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/modules<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/system</span>.webServer<span style="font-weight: bold; color: black;">&gt;</span></span></li></ol></div><div id="cb56016" style="display: none; color: red;"></div></div></div>

<p>Simple, and it works. Let's move on.</p>

<p>No TDD was involved in the making of this blogpost.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-iis-7-and-the">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-iis-7-and-the#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2142</wfw:commentRss>
		</item>
				<item>
			<title>Nancy and custom error pages.</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-custom-error-pages</link>
			<pubDate>Tue, 05 Feb 2013 09:59:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2079@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;I wanted to show my users some prettier errorpages then the default you get from IIS or &lt;a href=&quot;http://nancy.org&quot;&gt;Nancy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This being the default for Nancy. Because I know you guys like pictures.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError1.png?mtime=1360064701&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError1.png?mtime=1360064701&quot; width=&quot;552&quot; height=&quot;285&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Of course this was the first time ever in any webapp that I did that, So I had to look certain things up. And &lt;a href=&quot;http://www.asp.net/web-forms/tutorials/deployment/deploying-web-site-projects/displaying-a-custom-error-page-cs&quot;&gt;I thought this&lt;/a&gt; was pretty cool.&lt;/p&gt;

&lt;p&gt;But of course that&#039;s not how Nancy works.&lt;/p&gt;

&lt;p&gt;Nancy is a Lady, so we treat her like one.&lt;/p&gt;

&lt;p&gt;Setting it up.&lt;/p&gt;

&lt;p&gt;So first of we will have to change our webconfig so that it servers us custom errors.&lt;/p&gt;

&lt;p&gt;You do this by adding the following.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb58756&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;configuration&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;system&lt;/span&gt;.webServer&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;httpErrors&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;errorMode&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Custom&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;existingResponse&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;PassThrough&amp;quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/system&lt;/span&gt;.webServer&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/configuration&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb93661&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;Next up is to make a few html file that we can serve as our custom pages.&lt;/p&gt;

&lt;p&gt;Something like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb3622&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/html.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/head.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/title.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;404&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/body.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/p.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Special Chrissie 404 page&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb34964&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I made a similar one for 500.&lt;/p&gt;

&lt;p&gt;I named them 404.html and 500.html and made sure the properties of the files were set to embedded resource.&lt;/p&gt;

&lt;p&gt;Now I just had to create a custom IStatusCodeHandler, like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb12959&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports System.&lt;span style=&quot;color: #000000;&quot;&gt;IO&lt;/span&gt;&lt;br /&gt;Imports Nancy&lt;br /&gt;Imports Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;ErrorHandling&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; CustomErrors&lt;br /&gt;&amp;nbsp; &amp;nbsp; Implements IStatusCodeHandler&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; ReadOnly _errorPages &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; IDictionary&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of HttpStatusCode, &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; ReadOnly _supportedStatusCodes &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;HttpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;NotFound&lt;/span&gt;, HttpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;InternalServerError&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _errorPages = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Dictionary&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of HttpStatusCode, &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; From&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;HttpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;NotFound&lt;/span&gt;, LoadResource&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;404.html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;HttpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;InternalServerError&lt;/span&gt;, LoadResource&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;500.html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; Handle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; Implements IStatusCodeHandler.&lt;span style=&quot;color: #000000;&quot;&gt;Handle&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; AndAlso context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Contents&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; AndAlso Not ReferenceEquals&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Contents&lt;/span&gt;, Response.&lt;span style=&quot;color: #000000;&quot;&gt;NoBody&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; errorPage &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Not _errorPages.&lt;span style=&quot;color: #000000;&quot;&gt;TryGetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode, errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ModifyResponse&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode, context, errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; HandlesStatusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Boolean Implements IStatusCodeHandler.&lt;span style=&quot;color: #000000;&quot;&gt;HandlesStatusCode&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return _supportedStatusCodes.&lt;span style=&quot;color: #000000;&quot;&gt;Any&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; s = statusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; Shared &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; ModifyResponse&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext, errorPage &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Is&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; Response&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; With &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;StatusCode&lt;/span&gt; = statusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ContentType&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Contents&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Using writer = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; StreamWriter&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s, Encoding.&lt;span style=&quot;color: #000000;&quot;&gt;UTF8&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; writer.&lt;span style=&quot;color: #000000;&quot;&gt;Write&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Using&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; Shared &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; LoadResource&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;filename &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; resourceStream = GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CustomErrors&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Assembly&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetManifestResourceStream&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Format&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;WebApplication3.{0}&amp;quot;&lt;/span&gt;, filename&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If resourceStream &lt;span style=&quot;color: #0600FF;&quot;&gt;Is&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Empty&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Using reader = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; StreamReader&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;resourceStream&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return reader.&lt;span style=&quot;color: #000000;&quot;&gt;ReadToEnd&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Using&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb24484&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Normally one would expect Nancy to pick this file up, because Nancy is a good girl. (One of the many benefits of giving your framework a woman&#039;s name is all the nice cliches bloggers can use, Thank you for that) (One of the disadvantages is that Google has a dirty mind.)&lt;/p&gt;

&lt;p&gt;But Nancy has a bug, so you have to register it yourself. You can do this in the bootstrapper. I &lt;a href=&quot;https://github.com/NancyFx/Nancy/issues/951&quot;&gt;logged the bug in the github issuetracker&lt;/a&gt; so this might be resolved by the time you want to use this. &lt;span class=&quot;MT_red&quot;&gt;For your information, this bug was fixed 3 hours after logging it.&lt;/span&gt; &lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb21088&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;Bootstrapper&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; MyBootStrapper&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Inherits Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;DefaultNancyBootstrapper&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Protected Overrides ReadOnly &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; InternalConfiguration &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyInternalConfiguration&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return NancyInternalConfiguration.&lt;span style=&quot;color: #000000;&quot;&gt;WithOverrides&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;b&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b.&lt;span style=&quot;color: #000000;&quot;&gt;StatusCodeHandlers&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; List&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of Type&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; From &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CustomErrors&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb43329&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I&#039;m sure I killed a few puppies along the way. But it works. And here is the smoking gun.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError2.png?mtime=1360065383&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError2.png?mtime=1360065383&quot; width=&quot;193&quot; height=&quot;62&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Pretty, no?&lt;/p&gt;

&lt;p&gt;I have to thank &lt;a href=&quot;https://twitter.com/Grumpydev&quot;&gt;Steven Robbins&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/philliphaydon&quot;&gt;Phillip Haydon&lt;/a&gt; for their kind and generous help.&lt;/p&gt;

&lt;p&gt;And you can make it even better by using a masterpage. &lt;/p&gt;

&lt;p&gt;Just create a Master.html.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb73385&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/html.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/head.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/title.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;[Title]&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/Content/Css/main.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; /&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/body.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; [Details]&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb86512&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And see how I reference the css in my content folder.&lt;/p&gt;

&lt;p&gt;And then you can adapt the 404 and 500 page.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb62138&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/h2.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Page not found&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/p.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;We could not find the page you were looking for. Are you sure this is where you left it? This error is logged but I&#039;m pretty sure the administrator can not fix it.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/p.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;If it is urgent you can contact you admin by shouting real loud.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/p.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;BTW: You can find a link in the footer to the logfiles if you want to fix the error yourself.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb34711&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we go back to our CustomErrors class. And change the LoadResource method to this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb57853&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; Shared &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt; LoadResource&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; filename &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;ByVal&lt;/span&gt; httpStatusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; masterPageStream = GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CustomErrors&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Assembly&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetManifestResourceStream&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Format&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;BeCare_Server.{0}&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Master.html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; masterPage &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Using reader = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; StreamReader&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;masterPageStream&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; masterPage = reader.&lt;span style=&quot;color: #000000;&quot;&gt;ReadToEnd&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Using&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; masterPage = masterPage.&lt;span style=&quot;color: #000000;&quot;&gt;Replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;[Title]&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Format&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;Error {0}&amp;quot;&lt;/span&gt;, httpStatusCode.&lt;span style=&quot;color: #000000;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;D&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; resourceStream = GetType&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CustomErrors&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Assembly&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;GetManifestResourceStream&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Format&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;BeCare_Server.{0}&amp;quot;&lt;/span&gt;, filename&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If resourceStream &lt;span style=&quot;color: #0600FF;&quot;&gt;Is&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #0600FF;&quot;&gt;Empty&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; details &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Using reader = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; StreamReader&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;resourceStream&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; details = reader.&lt;span style=&quot;color: #000000;&quot;&gt;ReadToEnd&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; Using&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; masterPage = masterPage.&lt;span style=&quot;color: #000000;&quot;&gt;Replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;[Details]&amp;quot;&lt;/span&gt;, details&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return masterPage&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb88976&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And you can change your Handle method to this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb49297&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; Handle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; HttpStatusCode, context &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; NancyContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; Implements IStatusCodeHandler.&lt;span style=&quot;color: #000000;&quot;&gt;Handle&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; AndAlso context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Contents&lt;/span&gt; IsNot &lt;span style=&quot;color: #0600FF;&quot;&gt;Nothing&lt;/span&gt; AndAlso Not ReferenceEquals&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;context.&lt;span style=&quot;color: #000000;&quot;&gt;Response&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Contents&lt;/span&gt;, Response.&lt;span style=&quot;color: #000000;&quot;&gt;NoBody&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Dim&lt;/span&gt; errorPage &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Not _errorPages.&lt;span style=&quot;color: #000000;&quot;&gt;TryGetValue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode, errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IsNullOrEmpty&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; errorPage = LoadResource&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;&amp;quot;500.html&amp;quot;&lt;/span&gt;, statusCode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; If&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ModifyResponse&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;statusCode, context, errorPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb15763&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So that now every statuscode in the known world is handled by your custom errorpages. Of course this is optional.&lt;/p&gt;

&lt;p&gt;And now you get pretty page.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError3.png?mtime=1360074055&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError3.png?mtime=1360074055&quot; width=&quot;843&quot; height=&quot;751&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Cooooooooooollll!!!&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-custom-error-pages&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>I wanted to show my users some prettier errorpages then the default you get from IIS or <a href="http://nancy.org">Nancy</a>.</p>

<p>This being the default for Nancy. Because I know you guys like pictures.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError1.png?mtime=1360064701"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError1.png?mtime=1360064701" width="552" height="285" /></a></div>

<p>Of course this was the first time ever in any webapp that I did that, So I had to look certain things up. And <a href="http://www.asp.net/web-forms/tutorials/deployment/deploying-web-site-projects/displaying-a-custom-error-page-cs">I thought this</a> was pretty cool.</p>

<p>But of course that's not how Nancy works.</p>

<p>Nancy is a Lady, so we treat her like one.</p>

<p>Setting it up.</p>

<p>So first of we will have to change our webconfig so that it servers us custom errors.</p>

<p>You do this by adding the following.</p>

<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb61170'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb61170','cb30110'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb61170" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li2">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;system</span>.webServer<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;httpErrors</span> <span style="color: #000066;">errorMode</span>=<span style="color: #ff0000;">&quot;Custom&quot;</span> <span style="color: #000066;">existingResponse</span>=<span style="color: #ff0000;">&quot;PassThrough&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/system</span>.webServer<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span></li></ol></div><div id="cb30110" style="display: none; color: red;"></div></div></div>


<p>Next up is to make a few html file that we can serve as our custom pages.</p>

<p>Something like this.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb22821'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb22821','cb25313'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb22821" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>404<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></a></span>Special Chrissie 404 page<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></li></ol></div><div id="cb25313" style="display: none; color: red;"></div></div></div>

<p>I made a similar one for 500.</p>

<p>I named them 404.html and 500.html and made sure the properties of the files were set to embedded resource.</p>

<p>Now I just had to create a custom IStatusCodeHandler, like this.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb21446'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb21446','cb6330'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb21446" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports System.<span style="color: #000000;">IO</span></li><li style="" class="li2">Imports Nancy</li><li style="" class="li1">Imports Nancy.<span style="color: #000000;">ErrorHandling</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> CustomErrors</li><li style="" class="li2">&nbsp; &nbsp; Implements IStatusCodeHandler</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> ReadOnly _errorPages <span style="color: #0600FF;">As</span> IDictionary<span style="color: #000000;">&#40;</span>Of HttpStatusCode, <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> ReadOnly _supportedStatusCodes <span style="color: #0600FF;">As</span> HttpStatusCode<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> = <span style="color: #000000;">&#123;</span>HttpStatusCode.<span style="color: #000000;">NotFound</span>, HttpStatusCode.<span style="color: #000000;">InternalServerError</span><span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> <span style="color: #0600FF;">New</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; _errorPages = <span style="color: #0600FF;">New</span> Dictionary<span style="color: #000000;">&#40;</span>Of HttpStatusCode, <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span> From</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span>HttpStatusCode.<span style="color: #000000;">NotFound</span>, LoadResource<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;404.html&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span>HttpStatusCode.<span style="color: #000000;">InternalServerError</span>, LoadResource<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;500.html&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> Handle<span style="color: #000000;">&#40;</span>statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, context <span style="color: #0600FF;">As</span> NancyContext<span style="color: #000000;">&#41;</span> Implements IStatusCodeHandler.<span style="color: #000000;">Handle</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If context.<span style="color: #000000;">Response</span> IsNot <span style="color: #0600FF;">Nothing</span> AndAlso context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">Contents</span> IsNot <span style="color: #0600FF;">Nothing</span> AndAlso Not ReferenceEquals<span style="color: #000000;">&#40;</span>context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">Contents</span>, Response.<span style="color: #000000;">NoBody</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> errorPage <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If Not _errorPages.<span style="color: #000000;">TryGetValue</span><span style="color: #000000;">&#40;</span>statusCode, errorPage<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">String</span>.<span style="color: #000000;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>errorPage<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; ModifyResponse<span style="color: #000000;">&#40;</span>statusCode, context, errorPage<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Function</span> HandlesStatusCode<span style="color: #000000;">&#40;</span>statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, context <span style="color: #0600FF;">As</span> NancyContext<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> Boolean Implements IStatusCodeHandler.<span style="color: #000000;">HandlesStatusCode</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Return _supportedStatusCodes.<span style="color: #000000;">Any</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Function</span><span style="color: #000000;">&#40;</span>s<span style="color: #000000;">&#41;</span> s = statusCode<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> Shared <span style="color: #0600FF;">Sub</span> ModifyResponse<span style="color: #000000;">&#40;</span>statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, context <span style="color: #0600FF;">As</span> NancyContext, errorPage <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; If context.<span style="color: #000000;">Response</span> <span style="color: #0600FF;">Is</span> <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #000000;">Response</span> = <span style="color: #0600FF;">New</span> Response<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> With <span style="color: #000000;">&#123;</span>.<span style="color: #000000;">StatusCode</span> = statusCode<span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">ContentType</span> = <span style="color: #0600FF;">&quot;text/html&quot;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">Contents</span> = <span style="color: #0600FF;">Sub</span><span style="color: #000000;">&#40;</span>s<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Using writer = <span style="color: #0600FF;">New</span> StreamWriter<span style="color: #000000;">&#40;</span>s, Encoding.<span style="color: #000000;">UTF8</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.<span style="color: #000000;">Write</span><span style="color: #000000;">&#40;</span>errorPage<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Using</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> Shared <span style="color: #0600FF;">Function</span> LoadResource<span style="color: #000000;">&#40;</span>filename <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> resourceStream = GetType<span style="color: #000000;">&#40;</span>CustomErrors<span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Assembly</span>.<span style="color: #000000;">GetManifestResourceStream</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">String</span>.<span style="color: #000000;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;WebApplication3.{0}&quot;</span>, filename<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; If resourceStream <span style="color: #0600FF;">Is</span> <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">String</span>.<span style="color: #0600FF;">Empty</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Using reader = <span style="color: #0600FF;">New</span> StreamReader<span style="color: #000000;">&#40;</span>resourceStream<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return reader.<span style="color: #000000;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Using</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb6330" style="display: none; color: red;"></div></div></div>

<p>Normally one would expect Nancy to pick this file up, because Nancy is a good girl. (One of the many benefits of giving your framework a woman's name is all the nice cliches bloggers can use, Thank you for that) (One of the disadvantages is that Google has a dirty mind.)</p>

<p>But Nancy has a bug, so you have to register it yourself. You can do this in the bootstrapper. I <a href="https://github.com/NancyFx/Nancy/issues/951">logged the bug in the github issuetracker</a> so this might be resolved by the time you want to use this. <span class="MT_red">For your information, this bug was fixed 3 hours after logging it.</span> </p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb64972'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb64972','cb73849'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb64972" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports Nancy.<span style="color: #000000;">Bootstrapper</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> MyBootStrapper</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Inherits Nancy.<span style="color: #000000;">DefaultNancyBootstrapper</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Protected Overrides ReadOnly <span style="color: #0600FF;">Property</span> InternalConfiguration <span style="color: #0600FF;">As</span> NancyInternalConfiguration</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return NancyInternalConfiguration.<span style="color: #000000;">WithOverrides</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Sub</span><span style="color: #000000;">&#40;</span>b<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b.<span style="color: #000000;">StatusCodeHandlers</span> = <span style="color: #0600FF;">New</span> List<span style="color: #000000;">&#40;</span>Of Type<span style="color: #000000;">&#41;</span> From <span style="color: #000000;">&#123;</span>GetType<span style="color: #000000;">&#40;</span>CustomErrors<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Get</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Property</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb73849" style="display: none; color: red;"></div></div></div>

<p>I'm sure I killed a few puppies along the way. But it works. And here is the smoking gun.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError2.png?mtime=1360065383"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError2.png?mtime=1360065383" width="193" height="62" /></a></div>

<p>Pretty, no?</p>

<p>I have to thank <a href="https://twitter.com/Grumpydev">Steven Robbins</a> and <a href="https://twitter.com/philliphaydon">Phillip Haydon</a> for their kind and generous help.</p>

<p>And you can make it even better by using a masterpage. </p>

<p>Just create a Master.html.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb24571'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb24571','cb19249'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb24571" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>[Title]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;/Content/Css/main.css&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; [Details]</li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></li></ol></div><div id="cb19249" style="display: none; color: red;"></div></div></div>

<p>And see how I reference the css in my content folder.</p>

<p>And then you can adapt the 404 and 500 page.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb29350'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb29350','cb8115'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb29350" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/h2.html"><span style="color: #000000; font-weight: bold;">&lt;h2&gt;</span></a></span>Page not found<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></a></span>We could not find the page you were looking for. Are you sure this is where you left it? This error is logged but I'm pretty sure the administrator can not fix it.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></a></span>If it is urgent you can contact you admin by shouting real loud.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></a></span>BTW: You can find a link in the footer to the logfiles if you want to fix the error yourself.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></li></ol></div><div id="cb8115" style="display: none; color: red;"></div></div></div>

<p>Now we go back to our CustomErrors class. And change the LoadResource method to this.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb59341'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb59341','cb33532'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb59341" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Private</span> Shared <span style="color: #0600FF;">Function</span> LoadResource<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ByVal</span> filename <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span>, <span style="color: #0600FF;">ByVal</span> httpStatusCode <span style="color: #0600FF;">As</span> HttpStatusCode<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> masterPageStream = GetType<span style="color: #000000;">&#40;</span>CustomErrors<span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Assembly</span>.<span style="color: #000000;">GetManifestResourceStream</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">String</span>.<span style="color: #000000;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;BeCare_Server.{0}&quot;</span>, <span style="color: #0600FF;">&quot;Master.html&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> masterPage <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Using reader = <span style="color: #0600FF;">New</span> StreamReader<span style="color: #000000;">&#40;</span>masterPageStream<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; masterPage = reader.<span style="color: #000000;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Using</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; masterPage = masterPage.<span style="color: #000000;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;[Title]&quot;</span>, <span style="color: #0600FF;">String</span>.<span style="color: #000000;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;Error {0}&quot;</span>, httpStatusCode.<span style="color: #000000;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;D&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> resourceStream = GetType<span style="color: #000000;">&#40;</span>CustomErrors<span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Assembly</span>.<span style="color: #000000;">GetManifestResourceStream</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">String</span>.<span style="color: #000000;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;BeCare_Server.{0}&quot;</span>, filename<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; If resourceStream <span style="color: #0600FF;">Is</span> <span style="color: #0600FF;">Nothing</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return <span style="color: #0600FF;">String</span>.<span style="color: #0600FF;">Empty</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> details <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Using reader = <span style="color: #0600FF;">New</span> StreamReader<span style="color: #000000;">&#40;</span>resourceStream<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; details = reader.<span style="color: #000000;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> Using</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; masterPage = masterPage.<span style="color: #000000;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;[Details]&quot;</span>, details<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Return masterPage</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></li></ol></div><div id="cb33532" style="display: none; color: red;"></div></div></div>

<p>And you can change your Handle method to this.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb11798'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb11798','cb24146'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb11798" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Sub</span> Handle<span style="color: #000000;">&#40;</span>statusCode <span style="color: #0600FF;">As</span> HttpStatusCode, context <span style="color: #0600FF;">As</span> NancyContext<span style="color: #000000;">&#41;</span> Implements IStatusCodeHandler.<span style="color: #000000;">Handle</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If context.<span style="color: #000000;">Response</span> IsNot <span style="color: #0600FF;">Nothing</span> AndAlso context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">Contents</span> IsNot <span style="color: #0600FF;">Nothing</span> AndAlso Not ReferenceEquals<span style="color: #000000;">&#40;</span>context.<span style="color: #000000;">Response</span>.<span style="color: #000000;">Contents</span>, Response.<span style="color: #000000;">NoBody</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> errorPage <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If Not _errorPages.<span style="color: #000000;">TryGetValue</span><span style="color: #000000;">&#40;</span>statusCode, errorPage<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; If <span style="color: #0600FF;">String</span>.<span style="color: #000000;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>errorPage<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorPage = LoadResource<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">&quot;500.html&quot;</span>, statusCode<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> If</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; ModifyResponse<span style="color: #000000;">&#40;</span>statusCode, context, errorPage<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li></ol></div><div id="cb24146" style="display: none; color: red;"></div></div></div>

<p>So that now every statuscode in the known world is handled by your custom errorpages. Of course this is optional.</p>

<p>And now you get pretty page.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError3.png?mtime=1360074055"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/error/NancyError3.png?mtime=1360074055" width="843" height="751" /></a></div>

<p>Cooooooooooollll!!!</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-custom-error-pages">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-custom-error-pages#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2079</wfw:commentRss>
		</item>
				<item>
			<title>Nancy and adding the windows authenticated user to your page.</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-adding-the-windows</link>
			<pubDate>Mon, 04 Feb 2013 11:49:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="main">Server Programming</category>
<category domain="alt">ASP.NET</category>			<guid isPermaLink="false">2075@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;So I have been using Nancy and my IIS is configured to use windows authentication. &lt;/p&gt;

&lt;p&gt;Now how do I get the current authenticated user onto my webpage.&lt;/p&gt;

&lt;p&gt;But first of all how do I get the name of the current authenticated user. &lt;/p&gt;

&lt;p&gt;Well that was the simple part.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb74874&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;HttpContext.&lt;span style=&quot;color: #000000;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;User&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Identity&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb53383&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And there you have it.&lt;/p&gt;

&lt;p&gt;Now we all know that we can do this in Nancy with Razor to get the current logged in user when using formsauthentication or basic authentication.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb12243&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Url.&lt;span style=&quot;color: #000000;&quot;&gt;RenderContext&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Context&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;CurrentUser&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb16976&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course we could do this in our Module.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb61271&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Context.&lt;span style=&quot;color: #000000;&quot;&gt;CurrentUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; User With &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;UserName&lt;/span&gt; = HttpContext.&lt;span style=&quot;color: #000000;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;User&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Identity&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb45894&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And that would work, but it would become very tedious to repeat this for every module we have. So we have to look for a better way of doing this. And of course there is.&lt;/p&gt;

&lt;p&gt;We can make our own bootstrapper and change it in the nancy pipleine.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;vbnet&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;vbnet&quot; id=&quot;cb32335&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;Imports Nancy&lt;br /&gt;Imports Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;Security&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; BootStrapper&lt;br /&gt;&amp;nbsp; &amp;nbsp; Inherits DefaultNancyBootstrapper&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Protected Overrides &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt; ApplicationStartup&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;container &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; TinyIoc.&lt;span style=&quot;color: #000000;&quot;&gt;TinyIoCContainer&lt;/span&gt;, pipelines &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; Nancy.&lt;span style=&quot;color: #000000;&quot;&gt;Bootstrapper&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IPipelines&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;MyBase&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;ApplicationStartup&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;container, pipelines&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipelines.&lt;span style=&quot;color: #000000;&quot;&gt;AfterRequest&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;AddItemToEndOfPipeline&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ctx&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ctx.&lt;span style=&quot;color: #000000;&quot;&gt;CurrentUser&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;New&lt;/span&gt; User With &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;UserName&lt;/span&gt; = HttpContext.&lt;span style=&quot;color: #000000;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;User&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Identity&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Sub&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt; User&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Implements IUserIdentity&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; Claims &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; IEnumerable&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Of &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; Implements IUserIdentity.&lt;span style=&quot;color: #000000;&quot;&gt;Claims&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;Public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Property&lt;/span&gt; UserName &lt;span style=&quot;color: #0600FF;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;String&lt;/span&gt; Implements IUserIdentity.&lt;span style=&quot;color: #000000;&quot;&gt;UserName&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb60320&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So I added this to the AfterRequest hook And that changes the currentuser on every request for me.&lt;/p&gt;

&lt;p&gt;I also created a class User because CurrentUser needs a class that implements IUserIdentity. &lt;/p&gt;

&lt;p&gt;Cool huh.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-adding-the-windows&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>So I have been using Nancy and my IIS is configured to use windows authentication. </p>

<p>Now how do I get the current authenticated user onto my webpage.</p>

<p>But first of all how do I get the name of the current authenticated user. </p>

<p>Well that was the simple part.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb82700'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb82700','cb67235'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb82700" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">HttpContext.<span style="color: #000000;">Current</span>.<span style="color: #000000;">User</span>.<span style="color: #000000;">Identity</span>.<span style="color: #000000;">Name</span></li></ol></div><div id="cb67235" style="display: none; color: red;"></div></div></div>

<p>And there you have it.</p>

<p>Now we all know that we can do this in Nancy with Razor to get the current logged in user when using formsauthentication or basic authentication.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb35842'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb35842','cb3577'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb35842" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Url.<span style="color: #000000;">RenderContext</span>.<span style="color: #000000;">Context</span>.<span style="color: #000000;">CurrentUser</span></li></ol></div><div id="cb3577" style="display: none; color: red;"></div></div></div>

<p>Of course we could do this in our Module.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb97989'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb97989','cb50403'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb97989" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Context.<span style="color: #000000;">CurrentUser</span> = <span style="color: #0600FF;">New</span> User With <span style="color: #000000;">&#123;</span>.<span style="color: #000000;">UserName</span> = HttpContext.<span style="color: #000000;">Current</span>.<span style="color: #000000;">User</span>.<span style="color: #000000;">Identity</span>.<span style="color: #000000;">Name</span><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb50403" style="display: none; color: red;"></div></div></div>

<p>And that would work, but it would become very tedious to repeat this for every module we have. So we have to look for a better way of doing this. And of course there is.</p>

<p>We can make our own bootstrapper and change it in the nancy pipleine.</p>

<div class="codebox"><div class="codeheader"><span>vbnet</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb57071'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb57071','cb48317'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="vbnet" id="cb57071" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">Imports Nancy</li><li style="" class="li2">Imports Nancy.<span style="color: #000000;">Security</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Class</span> BootStrapper</li><li style="" class="li1">&nbsp; &nbsp; Inherits DefaultNancyBootstrapper</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; Protected Overrides <span style="color: #0600FF;">Sub</span> ApplicationStartup<span style="color: #000000;">&#40;</span>container <span style="color: #0600FF;">As</span> TinyIoc.<span style="color: #000000;">TinyIoCContainer</span>, pipelines <span style="color: #0600FF;">As</span> Nancy.<span style="color: #000000;">Bootstrapper</span>.<span style="color: #000000;">IPipelines</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">MyBase</span>.<span style="color: #000000;">ApplicationStartup</span><span style="color: #000000;">&#40;</span>container, pipelines<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; pipelines.<span style="color: #000000;">AfterRequest</span>.<span style="color: #000000;">AddItemToEndOfPipeline</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Sub</span><span style="color: #000000;">&#40;</span>ctx<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ctx.<span style="color: #000000;">CurrentUser</span> = <span style="color: #0600FF;">New</span> User With <span style="color: #000000;">&#123;</span>.<span style="color: #000000;">UserName</span> = HttpContext.<span style="color: #000000;">Current</span>.<span style="color: #000000;">User</span>.<span style="color: #000000;">Identity</span>.<span style="color: #000000;">Name</span><span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> <span style="color: #0600FF;">Class</span> User</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Implements IUserIdentity</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> Claims <span style="color: #0600FF;">As</span> IEnumerable<span style="color: #000000;">&#40;</span>Of <span style="color: #0600FF;">String</span><span style="color: #000000;">&#41;</span> Implements IUserIdentity.<span style="color: #000000;">Claims</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Public</span> <span style="color: #0600FF;">Property</span> UserName <span style="color: #0600FF;">As</span> <span style="color: #0600FF;">String</span> Implements IUserIdentity.<span style="color: #000000;">UserName</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></li></ol></div><div id="cb48317" style="display: none; color: red;"></div></div></div>

<p>So I added this to the AfterRequest hook And that changes the currentuser on every request for me.</p>

<p>I also created a class User because CurrentUser needs a class that implements IUserIdentity. </p>

<p>Cool huh.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-adding-the-windows">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/nancy-and-adding-the-windows#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2075</wfw:commentRss>
		</item>
				<item>
			<title>Angularjs and ng-grid</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/angularjs-and-ng-grid</link>
			<pubDate>Sun, 03 Feb 2013 17:23:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="alt">Javascript</category>
<category domain="main">AJAX</category>			<guid isPermaLink="false">2074@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Today I tried out &lt;a href=&quot;http://angularjs.org/&quot;&gt;Angularjs &lt;/a&gt;and &lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs&quot;&gt;posted about it&lt;/a&gt;. After that it was time to add a grid to make my data look better. And I picked &lt;a href=&quot;http://angular-ui.github.com/ng-grid/#/overview&quot;&gt;ng-grid&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;These are the packages I am using.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;angularjs 1.0.4&lt;/li&gt;
  &lt;li&gt;jQuery 1.9.0&lt;/li&gt;
  &lt;li&gt;Moment.js 1.7.2&lt;/li&gt;
  &lt;li&gt;ng-grid 1.6.0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the ng-grid package does not contain the scripts. So I had to get those manually. I took the ones on github. The ng-grid.1.6.3.js and ng-grid.css.&lt;/p&gt;

&lt;h2&gt;Server&lt;/h2&gt;

&lt;p&gt;See my &lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs&quot;&gt;previous post&lt;/a&gt; on angularjs for this.&lt;/p&gt;

&lt;h2&gt;Client&lt;/h2&gt;

&lt;p&gt;My app.js changes a little.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb94266&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;angular.module(&#039;plantsapp&#039;, [&#039;ngGrid&#039;]).&lt;br /&gt;&amp;nbsp; config([&#039;$routeProvider&#039;, function ($routeProvider) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $routeProvider.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants&#039;, { templateUrl: &#039;partials/plants.html&#039;, controller: PlantsController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants/:Id&#039;, { templateUrl: &#039;partials/plant.html&#039;, controller: PlantController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; otherwise({ redirectTo: &#039;/plants&#039; });&lt;br /&gt;&amp;nbsp; }]);&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb62988&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I just added the ngGrid string.&lt;/p&gt;

&lt;p&gt;My controller.js will change a little too. And then specifically my PlantsController.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb11736&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;function PlantsController($scope, $http) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $scope.plants = [];&lt;br /&gt;&amp;nbsp; &amp;nbsp; $scope.myOptions = { &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data: &#039;plants&#039;&lt;br /&gt;&amp;nbsp; &amp;nbsp; };&lt;br /&gt;&amp;nbsp; &amp;nbsp; $http.get(&#039;http://localhost:59025/plants&#039;).success(function (thisdata) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $scope.plants = thisdata;&lt;br /&gt;&amp;nbsp; &amp;nbsp; });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb34302&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;See how I instantiate my plants outside the get. And then I add the myOptions line.&lt;/p&gt;

&lt;p&gt;In the Index.html I will add these two lines.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb27496&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;css/ng-grid.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; /&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/Scripts/jquery-1.9.0.min.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/Scripts/ng-grid.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb86790&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And the plants.html file changes to this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb80548&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;div&lt;/span&gt;&lt;/a&gt; ng-grid=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;myOptions&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb31430&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The myOptions is the same as what property I added in my PlantsController.&lt;/p&gt;

&lt;p&gt;And tada.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs4.png?mtime=1359918800&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs4.png?mtime=1359918800&quot; width=&quot;910&quot; height=&quot;498&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;But you might see that the date is not well formatted. Let&#039;s fix that.&lt;/p&gt;

&lt;h2&gt;Formatting the date&lt;/h2&gt;

&lt;p&gt;First we need to add moment.js import to our index.html.&lt;/p&gt;

&lt;p&gt;Then we need to add a filter to our app.js.&lt;/p&gt;

&lt;p&gt;Like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb83247&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;angular.module(&#039;plantsapp&#039;, [&#039;ngGrid&#039;]).&lt;br /&gt;&amp;nbsp; config([&#039;$routeProvider&#039;, function ($routeProvider) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $routeProvider.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants&#039;, { templateUrl: &#039;partials/plants.html&#039;, controller: PlantsController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants/:Id&#039;, { templateUrl: &#039;partials/plant.html&#039;, controller: PlantController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; otherwise({ redirectTo: &#039;/plants&#039; });&lt;br /&gt;&amp;nbsp; }]).filter(&#039;moment&#039;, function () {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return function (dateString, format) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return moment(dateString).format(format);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;br /&gt;&amp;nbsp; });;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb28734&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And now we need to change our controller so that we can add this filter to our column definition for DateAdded.&lt;/p&gt;

&lt;p&gt;Like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb46527&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;function PlantsController($scope, $http) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $scope.plants = [];&lt;br /&gt;&amp;nbsp; &amp;nbsp; $scope.myOptions = { &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data: &#039;plants&#039;, &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; columnDefs: [&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {field:&#039;Id&#039;, displayName:&#039;Id&#039;},&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {field:&#039;Name&#039;, displayName:&#039;Name&#039;},&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { field: &#039;Genus&#039;, displayName: &#039;Genus&#039; },&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { field: &#039;DateAdded&#039;, displayName: &#039;Date added&#039;, cellFilter:&amp;quot;moment:&#039;DD/MM/YYYY h:m&#039;&amp;quot; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;br /&gt;&amp;nbsp; &amp;nbsp; };&lt;br /&gt;&amp;nbsp; &amp;nbsp; $http.get(&#039;http://localhost:59025/plants&#039;).success(function (thisdata) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $scope.plants = thisdata;&lt;br /&gt;&amp;nbsp; &amp;nbsp; });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb92592&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course we could set our fofrmat straight in the filter and and then just use the moment filter.&lt;/p&gt;

&lt;p&gt;For this we just need to change the filter to this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb90091&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;return moment(dateString).format(&#039;DD/MM/YYYY h:m&#039;);&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb88538&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and the columndefinition then becomes this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;js&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;js&quot; id=&quot;cb48305&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;{ field: &#039;DateAdded&#039;, displayName: &#039;Date added&#039;, cellFilter:&amp;quot;moment&amp;quot; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb86967&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And tada!!!!&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs3.png?mtime=1359918693&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs3.png?mtime=1359918693&quot; width=&quot;910&quot; height=&quot;498&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Once you get it ng-grid is pretty easy to set up. I just didn&#039;t get it for the first hour or so. Because I had my $scope.myOptions in my Get function, because that looked so much like what they did in the getting started things. But I was wrong.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/angularjs-and-ng-grid&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>Today I tried out <a href="http://angularjs.org/">Angularjs </a>and <a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs">posted about it</a>. After that it was time to add a grid to make my data look better. And I picked <a href="http://angular-ui.github.com/ng-grid/#/overview">ng-grid</a>.</p>

<h2>Installation</h2>

<p>These are the packages I am using.</p>

<ul>
  <li>angularjs 1.0.4</li>
  <li>jQuery 1.9.0</li>
  <li>Moment.js 1.7.2</li>
  <li>ng-grid 1.6.0</li>
</ul>

<p>But the ng-grid package does not contain the scripts. So I had to get those manually. I took the ones on github. The ng-grid.1.6.3.js and ng-grid.css.</p>

<h2>Server</h2>

<p>See my <a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs">previous post</a> on angularjs for this.</p>

<h2>Client</h2>

<p>My app.js changes a little.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb56377'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb56377','cb14506'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb56377" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">angular.module('plantsapp', ['ngGrid']).</li><li style="" class="li2">&nbsp; config(['$routeProvider', function ($routeProvider) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; $routeProvider.</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants', { templateUrl: 'partials/plants.html', controller: PlantsController }).</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants/:Id', { templateUrl: 'partials/plant.html', controller: PlantController }).</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; otherwise({ redirectTo: '/plants' });</li><li style="" class="li1">&nbsp; }]);</li></ol></div><div id="cb14506" style="display: none; color: red;"></div></div></div>

<p>I just added the ngGrid string.</p>

<p>My controller.js will change a little too. And then specifically my PlantsController.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb83029'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb83029','cb77879'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb83029" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">function PlantsController($scope, $http) {</li><li style="" class="li2">&nbsp; &nbsp; $scope.plants = [];</li><li style="" class="li1">&nbsp; &nbsp; $scope.myOptions = { </li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; data: 'plants'</li><li style="" class="li1">&nbsp; &nbsp; };</li><li style="" class="li2">&nbsp; &nbsp; $http.get('http://localhost:59025/plants').success(function (thisdata) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; $scope.plants = thisdata;</li><li style="" class="li2">&nbsp; &nbsp; });</li><li style="" class="li1">}</li></ol></div><div id="cb77879" style="display: none; color: red;"></div></div></div>

<p>See how I instantiate my plants outside the get. And then I add the myOptions line.</p>

<p>In the Index.html I will add these two lines.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb89189'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb89189','cb36111'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb89189" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;css/ng-grid.css&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;/Scripts/jquery-1.9.0.min.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;/Scripts/ng-grid.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li></ol></div><div id="cb36111" style="display: none; color: red;"></div></div></div>

<p>And the plants.html file changes to this.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb92603'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb92603','cb15341'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb92603" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> ng-grid=<span style="color: #ff0000;">&quot;myOptions&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></li></ol></div><div id="cb15341" style="display: none; color: red;"></div></div></div>

<p>The myOptions is the same as what property I added in my PlantsController.</p>

<p>And tada.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs4.png?mtime=1359918800"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs4.png?mtime=1359918800" width="910" height="498" /></a></div>

<p>But you might see that the date is not well formatted. Let's fix that.</p>

<h2>Formatting the date</h2>

<p>First we need to add moment.js import to our index.html.</p>

<p>Then we need to add a filter to our app.js.</p>

<p>Like this.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb62645'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb62645','cb11059'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb62645" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">angular.module('plantsapp', ['ngGrid']).</li><li style="" class="li2">&nbsp; config(['$routeProvider', function ($routeProvider) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; $routeProvider.</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants', { templateUrl: 'partials/plants.html', controller: PlantsController }).</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants/:Id', { templateUrl: 'partials/plant.html', controller: PlantController }).</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; otherwise({ redirectTo: '/plants' });</li><li style="" class="li1">&nbsp; }]).filter('moment', function () {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; return function (dateString, format) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return moment(dateString).format(format);</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; };</li><li style="" class="li1">&nbsp; });;</li></ol></div><div id="cb11059" style="display: none; color: red;"></div></div></div>

<p>And now we need to change our controller so that we can add this filter to our column definition for DateAdded.</p>

<p>Like this.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb95089'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb95089','cb61423'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb95089" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">function PlantsController($scope, $http) {</li><li style="" class="li2">&nbsp; &nbsp; $scope.plants = [];</li><li style="" class="li1">&nbsp; &nbsp; $scope.myOptions = { </li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; data: 'plants', </li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; columnDefs: [</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {field:'Id', displayName:'Id'},</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {field:'Name', displayName:'Name'},</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { field: 'Genus', displayName: 'Genus' },</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { field: 'DateAdded', displayName: 'Date added', cellFilter:&quot;moment:'DD/MM/YYYY h:m'&quot; }</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; ]</li><li style="" class="li1">&nbsp; &nbsp; };</li><li style="" class="li2">&nbsp; &nbsp; $http.get('http://localhost:59025/plants').success(function (thisdata) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; $scope.plants = thisdata;</li><li style="" class="li2">&nbsp; &nbsp; });</li><li style="" class="li1">}</li></ol></div><div id="cb61423" style="display: none; color: red;"></div></div></div>

<p>Of course we could set our fofrmat straight in the filter and and then just use the moment filter.</p>

<p>For this we just need to change the filter to this.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb29316'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb29316','cb54555'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb29316" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">return moment(dateString).format('DD/MM/YYYY h:m');</li></ol></div><div id="cb54555" style="display: none; color: red;"></div></div></div>

<p>and the columndefinition then becomes this.</p>

<div class="codebox"><div class="codeheader"><span>js</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb27183'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb27183','cb27358'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="js" id="cb27183" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">{ field: 'DateAdded', displayName: 'Date added', cellFilter:&quot;moment&quot; }</li></ol></div><div id="cb27358" style="display: none; color: red;"></div></div></div>

<p>And tada!!!!</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs3.png?mtime=1359918693"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs3.png?mtime=1359918693" width="910" height="498" /></a></div>

<h2>Conclusion</h2>

<p>Once you get it ng-grid is pretty easy to set up. I just didn't get it for the first hour or so. Because I had my $scope.myOptions in my Get function, because that looked so much like what they did in the getting started things. But I was wrong.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/angularjs-and-ng-grid">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/angularjs-and-ng-grid#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2074</wfw:commentRss>
		</item>
				<item>
			<title>Trying out Angularjs</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs</link>
			<pubDate>Sun, 03 Feb 2013 12:50:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="alt">ASP.NET</category>
<category domain="main">Javascript</category>
<category domain="alt">AJAX</category>			<guid isPermaLink="false">2071@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;It&#039;s superbowl Sunday and between the snacks it is time to learn something new. Today my eye fell on &lt;a href=&quot;http://angularjs.org/&quot;&gt;Angularjs&lt;/a&gt;. Angularjs is an MVC framework for javascript. It kinda puts the controllers and model on the clientside and not on the serverside like ASP.Net MVC does. I will use Nancy as our service to provide us with json data. &lt;/p&gt;

&lt;h2&gt;Server&lt;/h2&gt;

&lt;p&gt;Our server is pretty simple.&lt;/p&gt;

&lt;p&gt;Just make an empty asp.net application and add a Models folder.&lt;br /&gt;
Here is my model.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb78565&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; NancyJTable.&lt;span style=&quot;color: #0000FF;&quot;&gt;Models&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; PlantModel&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; Id &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get; set; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Name &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get; set; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Genus &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get; set; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Species &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get; set; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; DateTime DateAdded &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get; set; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb45773&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And here is my module, which I put in the Modules folder.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb11821&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Collections&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Generic&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Linq&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; Nancy;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; NancyJTable.&lt;span style=&quot;color: #0000FF;&quot;&gt;Models&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; NancyJTable.&lt;span style=&quot;color: #0000FF;&quot;&gt;Modules&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; PlantsModule:NancyModule&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; PlantsModule&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Get&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/plants/{Id}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; = parameters =&amp;gt; Response.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsJson&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;SingleOrDefault&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;x =&amp;gt; x.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt; == parameters.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Get&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/plants&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; = parameters =&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; Response.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsJson&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; IList&amp;lt;PlantModel&amp;gt; GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var plantModels = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; List&amp;lt;PlantModel&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;var i = &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;; i &amp;lt;= &lt;span style=&quot;color: #FF0000;&quot;&gt;25&lt;/span&gt;; i++&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var j = i.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;000&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; plantModels.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; PlantModel&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = i,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Genus = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;genus&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Species = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Species&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DateAdded = DateTime.&lt;span style=&quot;color: #0000FF;&quot;&gt;Now&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; plantModels;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb86588&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2&gt;Client&lt;/h2&gt;

&lt;p&gt;First I added another empty ASP.Net web application project to our solution.&lt;/p&gt;

&lt;p&gt;I added angularjs to my project. It is on nuget so no problems there.&lt;/p&gt;

&lt;p&gt;I want to add a list of plants and I want a details page. &lt;/p&gt;

&lt;p&gt;First I need to start with adding my app.j in the js folder. This will take care of the routes.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb63430&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;angular.module(&#039;plantsapp&#039;, []).&lt;br /&gt;&amp;nbsp; config([&#039;$routeProvider&#039;, function ($routeProvider) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $routeProvider.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants&#039;, { templateUrl: &#039;partials/plants.html&#039;, controller: PlantsController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when(&#039;/plants/:Id&#039;, { templateUrl: &#039;partials/plant.html&#039;, controller: PlantController }).&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; otherwise({ redirectTo: &#039;/plants&#039; });&lt;br /&gt;&amp;nbsp; }]);&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb82918&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You already see that I have two partial views and 2 controllers.&lt;/p&gt;

&lt;p&gt;The controllers are in my controllers.js file.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb75998&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;function PlantsController($scope, $http) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $http.get(&#039;http://localhost:59025/plants&#039;).success(function (data) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $scope.plants = data;&lt;br /&gt;&amp;nbsp; &amp;nbsp; });&lt;br /&gt;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;function PlantController($scope, $routeParams, $http) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $http.get(&#039;http://localhost:59025/plants/&#039; + $routeParams.Id).success(function (data) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $scope.plant = data;&lt;br /&gt;&amp;nbsp; &amp;nbsp; });&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb90818&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So I have a Plantscontroller that uses a get to get my json from my nancy service. And I have a PlantController that uses the routeparameter to tell which plant to get from my service. &lt;/p&gt;

&lt;p&gt;See how I inject http and how it magically gets injected for me.&lt;/p&gt;

&lt;p&gt;The next thing is to create an index.html which is the base of our views.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb66113&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/html.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;lang&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;en&amp;quot;&lt;/span&gt; ng-app=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;plantsapp&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/head.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/title.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Plants&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/Scripts/angular.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/js/controller.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/js/app.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/body.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;div&lt;/span&gt;&lt;/a&gt; ng-view&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb31667&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the html tag I added an ng-app with the name I provided in my app.js.&lt;/p&gt;

&lt;p&gt;I import angular.js, controller.js and app.js.&lt;/p&gt;

&lt;p&gt;And I added a div with an ng-view attribute.&lt;/p&gt;

&lt;p&gt;Now I need the partials which I put in the partials folder.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb47699&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/table.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;table&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;table_id&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/thead.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Id&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Name&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Genus&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;/thead&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tbody.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tbody&lt;/span&gt;&lt;/a&gt; ng-repeat=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;plant in plants&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/td.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;{{plant.Id}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/td.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/a.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;a&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;#/plants/{{plant.Id}}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;{{plant.Name}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/td.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;{{plant.Genus}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb8339&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is my plants.html file and it uses the plants object which I have added to the scope in my controller. &lt;/p&gt;

&lt;p&gt;See how I add the link (the # is important).&lt;/p&gt;

&lt;p&gt;The next file is the detail view, plant.html.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb21378&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/table.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;table&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;table_id&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Id&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;{{plant.Id}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Name&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;{{plant.Name}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Genus&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;{{plant.Genus}}&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb76573&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here I use plant because that is what I used to add the the scope in my controller.&lt;/p&gt;

&lt;p&gt;And that is it.&lt;/p&gt;

&lt;p&gt;Here are the screenshots. Look also at the url in the addressbarr.&lt;/p&gt;

&lt;p&gt;The plants.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs1.png?mtime=1359902777&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs1.png?mtime=1359902777&quot; width=&quot;733&quot; height=&quot;463&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;And here the detail view.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs2.png?mtime=1359902788&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs2.png?mtime=1359902788&quot; width=&quot;733&quot; height=&quot;463&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Yeah, uhm. Not sure. Not saying this is bad, but how will this scale ;-). One thing is for sure, the documentation was very good to get my started. Not that I read it before beginning but once I did, it helped.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>It's superbowl Sunday and between the snacks it is time to learn something new. Today my eye fell on <a href="http://angularjs.org/">Angularjs</a>. Angularjs is an MVC framework for javascript. It kinda puts the controllers and model on the clientside and not on the serverside like ASP.Net MVC does. I will use Nancy as our service to provide us with json data. </p>

<h2>Server</h2>

<p>Our server is pretty simple.</p>

<p>Just make an empty asp.net application and add a Models folder.<br />
Here is my model.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb81613'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb81613','cb46239'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb81613" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">namespace</span> NancyJTable.<span style="color: #0000FF;">Models</span></li><li style="" class="li2"><span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> PlantModel</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> Id <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Name <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Genus <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Species <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> DateTime DateAdded <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1"><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb46239" style="display: none; color: red;"></div></div></div>

<p>And here is my module, which I put in the Modules folder.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb14813'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb14813','cb67890'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb14813" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</li><li style="" class="li2"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;</li><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Linq</span>;</li><li style="" class="li2"><span style="color: #0600FF;">using</span> Nancy;</li><li style="" class="li1"><span style="color: #0600FF;">using</span> NancyJTable.<span style="color: #0000FF;">Models</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">namespace</span> NancyJTable.<span style="color: #0000FF;">Modules</span></li><li style="" class="li2"><span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> PlantsModule:NancyModule</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> PlantsModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;/plants/{Id}&quot;</span><span style="color: #000000;">&#93;</span> = parameters =&gt; Response.<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span>GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SingleOrDefault</span><span style="color: #000000;">&#40;</span>x =&gt; x.<span style="color: #0000FF;">Id</span> == parameters.<span style="color: #0000FF;">Id</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;/plants&quot;</span><span style="color: #000000;">&#93;</span> = parameters =&gt;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> Response.<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span>GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> IList&lt;PlantModel&gt; GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var plantModels = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List&lt;PlantModel&gt;<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span>var i = <span style="color: #FF0000;">1</span>; i &lt;= <span style="color: #FF0000;">25</span>; i++<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var j = i.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;000&quot;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plantModels.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> PlantModel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Id = i,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name = <span style="color: #808080;">&quot;name&quot;</span> + j,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Genus = <span style="color: #808080;">&quot;genus&quot;</span> + j,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Species = <span style="color: #808080;">&quot;Species&quot;</span> + j,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateAdded = DateTime.<span style="color: #0000FF;">Now</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> plantModels;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb67890" style="display: none; color: red;"></div></div></div>

<h2>Client</h2>

<p>First I added another empty ASP.Net web application project to our solution.</p>

<p>I added angularjs to my project. It is on nuget so no problems there.</p>

<p>I want to add a list of plants and I want a details page. </p>

<p>First I need to start with adding my app.j in the js folder. This will take care of the routes.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb67814'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb67814','cb5387'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb67814" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">angular.module('plantsapp', []).</li><li style="" class="li2">&nbsp; config(['$routeProvider', function ($routeProvider) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; $routeProvider.</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants', { templateUrl: 'partials/plants.html', controller: PlantsController }).</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when('/plants/:Id', { templateUrl: 'partials/plant.html', controller: PlantController }).</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; otherwise({ redirectTo: '/plants' });</li><li style="" class="li1">&nbsp; }]);</li></ol></div><div id="cb5387" style="display: none; color: red;"></div></div></div>

<p>You already see that I have two partial views and 2 controllers.</p>

<p>The controllers are in my controllers.js file.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb31520'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb31520','cb69040'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb31520" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">function PlantsController($scope, $http) {</li><li style="" class="li2">&nbsp; &nbsp; $http.get('http://localhost:59025/plants').success(function (data) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; $scope.plants = data;</li><li style="" class="li2">&nbsp; &nbsp; });</li><li style="" class="li1">}</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">function PlantController($scope, $routeParams, $http) {</li><li style="" class="li2">&nbsp; &nbsp; $http.get('http://localhost:59025/plants/' + $routeParams.Id).success(function (data) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; $scope.plant = data;</li><li style="" class="li2">&nbsp; &nbsp; });</li><li style="" class="li1">}</li></ol></div><div id="cb69040" style="display: none; color: red;"></div></div></div>

<p>So I have a Plantscontroller that uses a get to get my json from my nancy service. And I have a PlantController that uses the routeparameter to tell which plant to get from my service. </p>

<p>See how I inject http and how it magically gets injected for me.</p>

<p>The next thing is to create an index.html which is the base of our views.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb66308'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb66308','cb67432'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb66308" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span> ng-app=<span style="color: #ff0000;">&quot;plantsapp&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>Plants<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;/Scripts/angular.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;/js/controller.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;/js/app.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> ng-view&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></li></ol></div><div id="cb67432" style="display: none; color: red;"></div></div></div>

<p>In the html tag I added an ng-app with the name I provided in my app.js.</p>

<p>I import angular.js, controller.js and app.js.</p>

<p>And I added a div with an ng-view attribute.</p>

<p>Now I need the partials which I put in the partials folder.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb67735'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb67735','cb82488'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb67735" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;table_id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/thead.html"><span style="color: #000000; font-weight: bold;">&lt;thead&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Id<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Genus<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/thead&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tbody.html"><span style="color: #000000; font-weight: bold;">&lt;tbody</span></a> ng-repeat=<span style="color: #ff0000;">&quot;plant in plants&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>{{plant.Id}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;#/plants/{{plant.Id}}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{{plant.Name}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>{{plant.Genus}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></li></ol></div><div id="cb82488" style="display: none; color: red;"></div></div></div>

<p>This is my plants.html file and it uses the plants object which I have added to the scope in my controller. </p>

<p>See how I add the link (the # is important).</p>

<p>The next file is the detail view, plant.html.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb84329'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb84329','cb15586'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb84329" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;table_id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Id<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>{{plant.Id}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>{{plant.Name}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Genus<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>{{plant.Genus}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></li></ol></div><div id="cb15586" style="display: none; color: red;"></div></div></div>

<p>Here I use plant because that is what I used to add the the scope in my controller.</p>

<p>And that is it.</p>

<p>Here are the screenshots. Look also at the url in the addressbarr.</p>

<p>The plants.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs1.png?mtime=1359902777"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs1.png?mtime=1359902777" width="733" height="463" /></a></div>

<p>And here the detail view.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs2.png?mtime=1359902788"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/angularjs/angularjs2.png?mtime=1359902788" width="733" height="463" /></a></div>

<h2>Conclusion</h2>

<p>Yeah, uhm. Not sure. Not saying this is bad, but how will this scale ;-). One thing is for sure, the documentation was very good to get my started. Not that I read it before beginning but once I did, it helped.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/angularjs#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2071</wfw:commentRss>
		</item>
				<item>
			<title>Nancy and jquery datatables; formatting data</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables-formatting</link>
			<pubDate>Sun, 03 Feb 2013 07:25:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="alt">Server Programming</category>
<category domain="alt">ASP.NET</category>
<category domain="main">AJAX</category>			<guid isPermaLink="false">2069@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables&quot;&gt;Yesterday I started using jquery datatables&lt;/a&gt; and today I will play some more. I did this &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?p=2055&quot;&gt;blogpost using jtable&lt;/a&gt; before. And now I&#039;m gonna try the same thing and maybe a little more using datatables.&lt;/p&gt;

&lt;p&gt;This should be the result if everything goes well, which it never does from the first time, because Murphy is pairing with us.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables2.png?mtime=1359882239&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables2.png?mtime=1359882239&quot; width=&quot;910&quot; height=&quot;423&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Isn&#039;t it purdy?&lt;/p&gt;

&lt;p&gt;Ok it isn&#039;t but it works.&lt;/p&gt;

&lt;h2&gt;Adding a link&lt;/h2&gt;

&lt;p&gt;Making a column linkable is as easy as it was in jtable.&lt;/p&gt;

&lt;p&gt;In our aoColumns definition we just use mRender which takes a function.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb5396&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;mData&amp;quot;: &amp;quot;Name&amp;quot;, &amp;quot;sTitle&amp;quot;: &amp;quot;Name&amp;quot;, &amp;quot;sWidth&amp;quot;: &amp;quot;30%&amp;quot;, &amp;quot;bSortable&amp;quot;: false,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;mRender&amp;quot;: function (data, type, row) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return &#039;&amp;lt;a href=&amp;quot;/plants/&#039; + row.Id + &#039;&amp;quot;&amp;gt;&#039; + data + &#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb9958&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So data is the data for that cell, row is the object (in our case, could be an array too if your json datasource returns an array of arrays) and type is... not yet found a use for that.&lt;/p&gt;

&lt;h2&gt;Formatting our dates with time&lt;/h2&gt;

&lt;p&gt;As far as I can tell datatables has no way to format dates built in like jtable did. So we jump straight to moment.js.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb23967&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;mData&amp;quot;: &amp;quot;DateAdded&amp;quot;, &amp;quot;sTitle&amp;quot;: &amp;quot;Date added&amp;quot;, &amp;quot;sWidth&amp;quot;: &amp;quot;20%&amp;quot;, &amp;quot;bSortable&amp;quot;: false,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;mRender&amp;quot;: function (data, type, row) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return moment(data).format(&#039;DD/MM/YYYY HH:mm:ss&#039;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb22801&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Don&#039;t forget to add the moment.js nuget and import the moment.js file.&lt;/p&gt;

&lt;h2&gt;Color a row based on something&lt;/h2&gt;

&lt;p&gt;In Excel they call this conditional formatting. In the example above I made all the rows lightcoral where the id was divisable by 3. &lt;/p&gt;

&lt;p&gt;My first attempt was this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb85287&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;quot;fnRowCallback&amp;quot;: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ( aData.Id % 3 == 0 )&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(nRow).css(&#039;background-color&#039;, &#039;lightcoral&#039;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(nRow).css(&#039;color&#039;, &#039;white&#039;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb30013&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables3.png?mtime=1359883342&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables3.png?mtime=1359883342&quot; width=&quot;910&quot; height=&quot;423&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;And that is not the desired result because someone is overriding my nice formatting with their own on a td level, bad, bad people.&lt;/p&gt;

&lt;p&gt;But I can be mean too. And this will work.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb53134&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;quot;fnRowCallback&amp;quot;: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ( aData.Id % 3 == 0 )&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(&#039;td&#039;, nRow).css(&#039;background-color&#039;, &#039;lightcoral&#039;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(&#039;td&#039;, nRow).css(&#039;color&#039;, &#039;white&#039;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb62820&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;It&#039;s fairly easy to bend the data to your will and format things as you desire.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables-formatting&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p><a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables">Yesterday I started using jquery datatables</a> and today I will play some more. I did this <a href="http://blogs.lessthandot.com/index.php/All/?p=2055">blogpost using jtable</a> before. And now I'm gonna try the same thing and maybe a little more using datatables.</p>

<p>This should be the result if everything goes well, which it never does from the first time, because Murphy is pairing with us.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables2.png?mtime=1359882239"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables2.png?mtime=1359882239" width="910" height="423" /></a></div>

<p>Isn't it purdy?</p>

<p>Ok it isn't but it works.</p>

<h2>Adding a link</h2>

<p>Making a column linkable is as easy as it was in jtable.</p>

<p>In our aoColumns definition we just use mRender which takes a function.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb91739'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb91739','cb65184'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb91739" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">{</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;mData&quot;: &quot;Name&quot;, &quot;sTitle&quot;: &quot;Name&quot;, &quot;sWidth&quot;: &quot;30%&quot;, &quot;bSortable&quot;: false,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;mRender&quot;: function (data, type, row) {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return '&lt;a href=&quot;/plants/' + row.Id + '&quot;&gt;' + data + '&lt;/a&gt;';</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li></ol></div><div id="cb65184" style="display: none; color: red;"></div></div></div>

<p>So data is the data for that cell, row is the object (in our case, could be an array too if your json datasource returns an array of arrays) and type is... not yet found a use for that.</p>

<h2>Formatting our dates with time</h2>

<p>As far as I can tell datatables has no way to format dates built in like jtable did. So we jump straight to moment.js.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb24841'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb24841','cb66122'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb24841" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">{</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;mData&quot;: &quot;DateAdded&quot;, &quot;sTitle&quot;: &quot;Date added&quot;, &quot;sWidth&quot;: &quot;20%&quot;, &quot;bSortable&quot;: false,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;mRender&quot;: function (data, type, row) {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return moment(data).format('DD/MM/YYYY HH:mm:ss');</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li></ol></div><div id="cb66122" style="display: none; color: red;"></div></div></div>

<p>Don't forget to add the moment.js nuget and import the moment.js file.</p>

<h2>Color a row based on something</h2>

<p>In Excel they call this conditional formatting. In the example above I made all the rows lightcoral where the id was divisable by 3. </p>

<p>My first attempt was this.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb30095'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb30095','cb98138'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb30095" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&quot;fnRowCallback&quot;: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( aData.Id % 3 == 0 )</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(nRow).css('background-color', 'lightcoral');</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(nRow).css('color', 'white');</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li></ol></div><div id="cb98138" style="display: none; color: red;"></div></div></div>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables3.png?mtime=1359883342"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables3.png?mtime=1359883342" width="910" height="423" /></a></div>

<p>And that is not the desired result because someone is overriding my nice formatting with their own on a td level, bad, bad people.</p>

<p>But I can be mean too. And this will work.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb29682'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb29682','cb72157'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb29682" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&quot;fnRowCallback&quot;: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( aData.Id % 3 == 0 )</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('td', nRow).css('background-color', 'lightcoral');</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('td', nRow).css('color', 'white');</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li></ol></div><div id="cb72157" style="display: none; color: red;"></div></div></div>

<h2>Conclusion</h2>

<p>It's fairly easy to bend the data to your will and format things as you desire.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables-formatting">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables-formatting#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2069</wfw:commentRss>
		</item>
				<item>
			<title>Nancy and jquery datatables</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables</link>
			<pubDate>Sat, 02 Feb 2013 17:03:00 +0000</pubDate>			<dc:creator>Christiaan Baes (chrissie1)</dc:creator>
			<category domain="alt">Server Programming</category>
<category domain="alt">ASP.NET</category>
<category domain="main">AJAX</category>			<guid isPermaLink="false">2068@http://blogs.lessthandot.com/</guid>
						<description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Another weekend, another bit of testing to do. Lately I have been doing a lot of webdev so I am looking to improve my skills and test things during the weekend. Last weekend I tested &lt;a href=&quot;http://jtable.org/&quot;&gt;jtable &lt;/a&gt;and even have it in production. But we are always on the lookout for better and it was suggested to me to try &lt;a href=&quot;http://www.datatables.net/index&quot;&gt;datatables&lt;/a&gt;. Which I did.&lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;Documentation for datatables is kind of lacking in that it leaves out important information to get all the bits working.&lt;/p&gt;

&lt;p&gt;So here is the list of nuget packages I used.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;jQuery 1.9.0&lt;/li&gt;
  &lt;li&gt;jquery.datatables 1.9.4&lt;/li&gt;
  &lt;li&gt;jQuery.UI.Combined 1.10.0&lt;/li&gt;
  &lt;li&gt;Nancy 0.15.3&lt;/li&gt;
  &lt;li&gt;Nancy.Hosting.Aspnet 0.15.3&lt;/li&gt;
  &lt;li&gt;Nancy.Viewengines.Razor 0.15.3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing that is on nuget but does not really work are the jquery-ui themes for the themeroller. But not to worry you can &lt;a href=&quot;http://jqueryui.com/download&quot;&gt;download them from the site&lt;/a&gt; and just add them manually (yuck).&lt;/p&gt;

&lt;p&gt;Don&#039;t forget to copy your Scripts folder to the Content folder. Not sure if I can tell nuget how to do this in future but that would be nice. Anyway.&lt;/p&gt;

&lt;p&gt;Now we have all the bits. Here is the code.&lt;/p&gt;

&lt;h2&gt;Nancy&lt;/h2&gt;

&lt;p&gt;I will use my PlantModel from &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?p=2049&quot;&gt;the previous blogpost&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But I will have to change my PLantsmodule to look like this.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb98672&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Collections&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Generic&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Linq&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; Nancy;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; Nancy.&lt;span style=&quot;color: #0000FF;&quot;&gt;ModelBinding&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; NancyJTable.&lt;span style=&quot;color: #0000FF;&quot;&gt;Models&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Linq&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; NancyJTable.&lt;span style=&quot;color: #0000FF;&quot;&gt;Modules&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; PlantsModule:NancyModule&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; PlantsModule&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Get&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; = parameters =&amp;gt; View&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Plants&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Get&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/plants/{Id}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; = parameters =&amp;gt; View&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;SingleOrDefault&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;x =&amp;gt; x.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt; == parameters.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Get&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/plants&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; = parameters =&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; start = Convert.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToInt32&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Request.&lt;span style=&quot;color: #0000FF;&quot;&gt;Query&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;iDisplayStart&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; length = Convert.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToInt32&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Request.&lt;span style=&quot;color: #0000FF;&quot;&gt;Query&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;iDisplayLength&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var totalRecords = GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Count&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var secho = Request.&lt;span style=&quot;color: #0000FF;&quot;&gt;Query&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;sEcho&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var sorting = Request.&lt;span style=&quot;color: #0000FF;&quot;&gt;Query&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;sSortDir_0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;sorting == &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;asc&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; Response.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsJson&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; aaData = GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;OrderBy&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;x =&amp;gt; x.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Skip&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;start&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Take&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;length&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, sEcho = secho, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; Response.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsJson&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; aaData = GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;OrderByDescending&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;x =&amp;gt; x.&lt;span style=&quot;color: #0000FF;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Skip&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;start&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Take&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;length&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, sEcho = secho.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; IList&amp;lt;PlantModel&amp;gt; GetPlantModels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var plantModels = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; List&amp;lt;PlantModel&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;var i = &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;; i &amp;lt;= &lt;span style=&quot;color: #FF0000;&quot;&gt;25&lt;/span&gt;; i++&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var j = i.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;000&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; plantModels.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; PlantModel&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = i,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Genus = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;genus&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Species = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Species&amp;quot;&lt;/span&gt; + j,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DateAdded = DateTime.&lt;span style=&quot;color: #0000FF;&quot;&gt;Now&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; plantModels;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb9243&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;See how use a Get? See how I get the paging parameters (iDisplayStart and iDisplayLength). I only allow the user to resort the Id column so I am slightly cheating here. You can find all &lt;a href=&quot;http://www.datatables.net/usage/server-side&quot;&gt;the parameters here.&lt;/a&gt; You also need to get sEcho and just pass it back out. &lt;/p&gt;

&lt;p&gt;The output will look something like this in json.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;text&quot; id=&quot;cb58555&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;quot;sEcho&amp;quot;: 3,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;quot;iTotalRecords&amp;quot;: 57,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;quot;iTotalDisplayRecords&amp;quot;: 57,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;quot;aaData&amp;quot;: [&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Id&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Name&amp;quot;: &amp;quot;Name1&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Genus&amp;quot;: &amp;quot;Genus1&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Species&amp;quot;: &amp;quot;Species1&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;DateAdded&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;br /&gt;&amp;nbsp; &amp;nbsp; ]&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb5537&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Which is an objectnotation. Let&#039;s remember that fact because it is pretty important later on. ;-)&lt;/p&gt;

&lt;h2&gt;Datatables&lt;/h2&gt;

&lt;p&gt;And here is the view code.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;html&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;html&quot; id=&quot;cb5955&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;@using Nancy&lt;br /&gt;&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/html.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/head.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/title.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Plants&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/themes/smoothness/jquery-ui.css&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; /&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/themes/smoothness/jquery.ui.theme.css&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; /&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/DataTables&lt;span style=&quot;color: #cc66cc;&quot;&gt;-1.9&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;.4&lt;/span&gt;/&lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;/css/jquery.dataTables_themeroller.css&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; /&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/Scripts/jquery&lt;span style=&quot;color: #cc66cc;&quot;&gt;-1.9&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;.0&lt;/span&gt;.min.js&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/Scripts/jquery-ui&lt;span style=&quot;color: #cc66cc;&quot;&gt;-1.10&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;.0&lt;/span&gt;.min.js&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/Scripts/DataTables&lt;span style=&quot;color: #cc66cc;&quot;&gt;-1.9&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;.4&lt;/span&gt;/&lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;/js/jquery.dataTables.min.js&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;~/&lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;/Scripts/DataTables&lt;span style=&quot;color: #cc66cc;&quot;&gt;-1.9&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;.4&lt;/span&gt;/&lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;/js/jquery.dataTables.ColumnResizeAndReorder.js&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(document).ready(function () {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $(&#039;#table_id&#039;).dataTable({&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;bProcessing&amp;quot;: true,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;bStateSave&amp;quot;: true,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;bServerSide&amp;quot;: true,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;bJQueryUI&amp;quot;: true,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;bFilter&amp;quot;: false,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;sAjaxSource&amp;quot;: &amp;quot;/plants&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;sDom&amp;quot;: &#039;R&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataTables_HeaderWrapper&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;H&amp;quot;&lt;/span&gt;lfr&amp;gt;&lt;/span&gt;&amp;gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataTables_BodyWrapper&amp;quot;&lt;/span&gt;t&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataTables_FooterWrapper&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;F&amp;quot;&lt;/span&gt;ip&amp;gt;&lt;/span&gt;&amp;gt;&#039;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;aoColumns&amp;quot;: [&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;quot;mData&amp;quot;: &amp;quot;Id&amp;quot;, &amp;quot;sTitle&amp;quot;: &amp;quot;Id&amp;quot;, &amp;quot;sWidth&amp;quot;: &amp;quot;20%&amp;quot;, &amp;quot;bSortable&amp;quot;: true },&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;quot;mData&amp;quot;: &amp;quot;Name&amp;quot;, &amp;quot;sTitle&amp;quot;: &amp;quot;Name&amp;quot;, &amp;quot;sWidth&amp;quot;: &amp;quot;40%&amp;quot;, &amp;quot;bSortable&amp;quot;: false },&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;quot;mData&amp;quot;: &amp;quot;Genus&amp;quot;, &amp;quot;sTitle&amp;quot;: &amp;quot;Genus1&amp;quot;, &amp;quot;sWidth&amp;quot;: &amp;quot;40%&amp;quot;, &amp;quot;bSortable&amp;quot;: false }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;sPaginationType&amp;quot;: &amp;quot;full_numbers&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;fnServerData&amp;quot;: function (sSource, aoData, fnCallback) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $.getJSON(sSource, aoData, function (jsondata) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fnCallback(jsondata);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/body.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/table.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;table&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;table_id&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/thead.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Id&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Name&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/th.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;Genus&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;/thead&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tbody.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/tr.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/td.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;td&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;colspan&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;3&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataTables_empty&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Loading data from server&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;dataoutput&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb65391&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I also have a plugin to resize the columns because that is not something that is builtin with datatables. You can find &lt;a href=&quot;http://www.datatables.net/extras/&quot;&gt;that plugin&lt;/a&gt; on the extras page of the datatables website.&lt;/p&gt;

&lt;p&gt;It is important that we use mData for our columns for because we use objectnotation in our json. The fnServerData has the function that gets our json data. &lt;/p&gt;

&lt;p&gt;Look at the html. You need a lot more html than most other frameworks. But it works. Well not actually sure you need that much html because this is one of the parts where the docs are a bit lacking. &lt;/p&gt;

&lt;p&gt;It was also lacking on which libraries to import (js and css) but you now have all of them in the code above. &lt;/p&gt;

&lt;p&gt;And this is the result.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables1.png?mtime=1359831744&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables1.png?mtime=1359831744&quot; width=&quot;857&quot; height=&quot;560&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Is datatables better than jtable? Pff, nah. But I can use a Get instead of a Post to get my data and that is an improvement.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>Another weekend, another bit of testing to do. Lately I have been doing a lot of webdev so I am looking to improve my skills and test things during the weekend. Last weekend I tested <a href="http://jtable.org/">jtable </a>and even have it in production. But we are always on the lookout for better and it was suggested to me to try <a href="http://www.datatables.net/index">datatables</a>. Which I did.</p>

<h2>Installation</h2>

<p>Documentation for datatables is kind of lacking in that it leaves out important information to get all the bits working.</p>

<p>So here is the list of nuget packages I used.</p>

<ul>
  <li>jQuery 1.9.0</li>
  <li>jquery.datatables 1.9.4</li>
  <li>jQuery.UI.Combined 1.10.0</li>
  <li>Nancy 0.15.3</li>
  <li>Nancy.Hosting.Aspnet 0.15.3</li>
  <li>Nancy.Viewengines.Razor 0.15.3</li>
</ul>

<p>One thing that is on nuget but does not really work are the jquery-ui themes for the themeroller. But not to worry you can <a href="http://jqueryui.com/download">download them from the site</a> and just add them manually (yuck).</p>

<p>Don't forget to copy your Scripts folder to the Content folder. Not sure if I can tell nuget how to do this in future but that would be nice. Anyway.</p>

<p>Now we have all the bits. Here is the code.</p>

<h2>Nancy</h2>

<p>I will use my PlantModel from <a href="http://blogs.lessthandot.com/index.php/All/?p=2049">the previous blogpost</a>.</p>

<p>But I will have to change my PLantsmodule to look like this.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb59745'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb59745','cb64485'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb59745" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</li><li style="" class="li2"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;</li><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Linq</span>;</li><li style="" class="li2"><span style="color: #0600FF;">using</span> Nancy;</li><li style="" class="li1"><span style="color: #0600FF;">using</span> Nancy.<span style="color: #0000FF;">ModelBinding</span>;</li><li style="" class="li2"><span style="color: #0600FF;">using</span> NancyJTable.<span style="color: #0000FF;">Models</span>;</li><li style="" class="li1"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Linq</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">namespace</span> NancyJTable.<span style="color: #0000FF;">Modules</span></li><li style="" class="li2"><span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> PlantsModule:NancyModule</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> PlantsModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;/&quot;</span><span style="color: #000000;">&#93;</span> = parameters =&gt; View<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;Plants&quot;</span><span style="color: #000000;">&#93;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;/plants/{Id}&quot;</span><span style="color: #000000;">&#93;</span> = parameters =&gt; View<span style="color: #000000;">&#91;</span>GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SingleOrDefault</span><span style="color: #000000;">&#40;</span>x =&gt; x.<span style="color: #0000FF;">Id</span> == parameters.<span style="color: #0000FF;">Id</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get<span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;/plants&quot;</span><span style="color: #000000;">&#93;</span> = parameters =&gt;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> start = Convert.<span style="color: #0000FF;">ToInt32</span><span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">Query</span>.<span style="color: #0000FF;">iDisplayStart</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> length = Convert.<span style="color: #0000FF;">ToInt32</span><span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">Query</span>.<span style="color: #0000FF;">iDisplayLength</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var totalRecords = GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var secho = Request.<span style="color: #0000FF;">Query</span>.<span style="color: #0000FF;">sEcho</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var sorting = Request.<span style="color: #0000FF;">Query</span>.<span style="color: #0000FF;">sSortDir_0</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>sorting == <span style="color: #808080;">&quot;asc&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> Response.<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">&#123;</span> aaData = GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">OrderBy</span><span style="color: #000000;">&#40;</span>x =&gt; x.<span style="color: #0000FF;">Id</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Skip</span><span style="color: #000000;">&#40;</span>start<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Take</span><span style="color: #000000;">&#40;</span>length<span style="color: #000000;">&#41;</span>, sEcho = secho, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">else</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> Response.<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">&#123;</span> aaData = GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">OrderByDescending</span><span style="color: #000000;">&#40;</span>x =&gt; x.<span style="color: #0000FF;">Id</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Skip</span><span style="color: #000000;">&#40;</span>start<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Take</span><span style="color: #000000;">&#40;</span>length<span style="color: #000000;">&#41;</span>, sEcho = secho.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> IList&lt;PlantModel&gt; GetPlantModels<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var plantModels = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List&lt;PlantModel&gt;<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span>var i = <span style="color: #FF0000;">1</span>; i &lt;= <span style="color: #FF0000;">25</span>; i++<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var j = i.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;000&quot;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plantModels.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> PlantModel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Id = i,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name = <span style="color: #808080;">&quot;name&quot;</span> + j,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Genus = <span style="color: #808080;">&quot;genus&quot;</span> + j,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Species = <span style="color: #808080;">&quot;Species&quot;</span> + j,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateAdded = DateTime.<span style="color: #0000FF;">Now</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> plantModels;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1"><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb64485" style="display: none; color: red;"></div></div></div>

<p>See how use a Get? See how I get the paging parameters (iDisplayStart and iDisplayLength). I only allow the user to resort the Id column so I am slightly cheating here. You can find all <a href="http://www.datatables.net/usage/server-side">the parameters here.</a> You also need to get sEcho and just pass it back out. </p>

<p>The output will look something like this in json.</p>

<div class="codebox"><div class="codeheader"><span>text</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb95886'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb95886','cb56976'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="text" id="cb95886" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">{</li><li style="" class="li2">&nbsp; &nbsp; &quot;sEcho&quot;: 3,</li><li style="" class="li1">&nbsp; &nbsp; &quot;iTotalRecords&quot;: 57,</li><li style="" class="li2">&nbsp; &nbsp; &quot;iTotalDisplayRecords&quot;: 57,</li><li style="" class="li1">&nbsp; &nbsp; &quot;aaData&quot;: [</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Id&quot;: &quot;1&quot;,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Name&quot;: &quot;Name1&quot;,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Genus&quot;: &quot;Genus1&quot;,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Species&quot;: &quot;Species1&quot;,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;DateAdded&quot;: &quot;&quot;,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; },</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; ...</li><li style="" class="li2">&nbsp; &nbsp; ]</li><li style="" class="li1">}</li></ol></div><div id="cb56976" style="display: none; color: red;"></div></div></div>

<p>Which is an objectnotation. Let's remember that fact because it is pretty important later on. ;-)</p>

<h2>Datatables</h2>

<p>And here is the view code.</p>

<div class="codebox"><div class="codeheader"><span>html</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb96396'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb96396','cb68659'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="html" id="cb96396" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">@using Nancy</li><li style="" class="li2"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span></li><li style="" class="li1"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>Plants<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/themes/smoothness/jquery-ui.css<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/themes/smoothness/jquery.ui.theme.css<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/DataTables<span style="color: #cc66cc;">-1.9</span><span style="color: #cc66cc;">.4</span>/<span style="color: #000066;">media</span>/css/jquery.dataTables_themeroller.css<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/Scripts/jquery<span style="color: #cc66cc;">-1.9</span><span style="color: #cc66cc;">.0</span>.min.js<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/Scripts/jquery-ui<span style="color: #cc66cc;">-1.10</span><span style="color: #cc66cc;">.0</span>.min.js<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/Scripts/DataTables<span style="color: #cc66cc;">-1.9</span><span style="color: #cc66cc;">.4</span>/<span style="color: #000066;">media</span>/js/jquery.dataTables.min.js<span style="color: #ff0000;">&quot;)&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;@Url.Content(&quot;</span>~/<span style="color: #000066;">Content</span>/Scripts/DataTables<span style="color: #cc66cc;">-1.9</span><span style="color: #cc66cc;">.4</span>/<span style="color: #000066;">media</span>/js/jquery.dataTables.ColumnResizeAndReorder.js<span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; $(document).ready(function () {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#table_id').dataTable({</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;bProcessing&quot;: true,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;bStateSave&quot;: true,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;bServerSide&quot;: true,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;bJQueryUI&quot;: true,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;bFilter&quot;: false,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;sAjaxSource&quot;: &quot;/plants&quot;,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;sDom&quot;: 'R<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #ff0000;">&quot;dataTables_HeaderWrapper&quot;</span><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #ff0000;">&quot;H&quot;</span>lfr&gt;</span>&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #ff0000;">&quot;dataTables_BodyWrapper&quot;</span>t&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #ff0000;">&quot;dataTables_FooterWrapper&quot;</span><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #ff0000;">&quot;F&quot;</span>ip&gt;</span>&gt;',</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;aoColumns&quot;: [</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &quot;mData&quot;: &quot;Id&quot;, &quot;sTitle&quot;: &quot;Id&quot;, &quot;sWidth&quot;: &quot;20%&quot;, &quot;bSortable&quot;: true },</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &quot;mData&quot;: &quot;Name&quot;, &quot;sTitle&quot;: &quot;Name&quot;, &quot;sWidth&quot;: &quot;40%&quot;, &quot;bSortable&quot;: false },</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &quot;mData&quot;: &quot;Genus&quot;, &quot;sTitle&quot;: &quot;Genus1&quot;, &quot;sWidth&quot;: &quot;40%&quot;, &quot;bSortable&quot;: false }</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;sPaginationType&quot;: &quot;full_numbers&quot;,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;fnServerData&quot;: function (sSource, aoData, fnCallback) {</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.getJSON(sSource, aoData, function (jsondata) {</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fnCallback(jsondata);</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; });</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;table_id&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/thead.html"><span style="color: #000000; font-weight: bold;">&lt;thead&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Id<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th&gt;</span></a></span>Genus<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/thead&gt;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tbody.html"><span style="color: #000000; font-weight: bold;">&lt;tbody&gt;</span></a></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">colspan</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;dataTables_empty&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Loading data from server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataoutput&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></li></ol></div><div id="cb68659" style="display: none; color: red;"></div></div></div>

<p>I also have a plugin to resize the columns because that is not something that is builtin with datatables. You can find <a href="http://www.datatables.net/extras/">that plugin</a> on the extras page of the datatables website.</p>

<p>It is important that we use mData for our columns for because we use objectnotation in our json. The fnServerData has the function that gets our json data. </p>

<p>Look at the html. You need a lot more html than most other frameworks. But it works. Well not actually sure you need that much html because this is one of the parts where the docs are a bit lacking. </p>

<p>It was also lacking on which libraries to import (js and css) but you now have all of them in the code above. </p>

<p>And this is the result.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables1.png?mtime=1359831744"><img alt="" src="http://blogs.lessthandot.com/media/users/chrissie1/nancy/nancydatatables1.png?mtime=1359831744" width="857" height="560" /></a></div>

<h2>Conclusion</h2>

<p>Is datatables better than jtable? Pff, nah. But I can use a Get instead of a Post to get my data and that is an improvement.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/AJAX/nancy-and-jquery-datatables#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=2068</wfw:commentRss>
		</item>
			</channel>
</rss>
