<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Gunnar Peipman's ASP.NET blog</title><link>http://weblogs.asp.net/gunnarpeipman/default.aspx</link><description>ASP.NET, C#, SharePoint, SQL Server and general software development topics.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/gunnarpeipman" /><feedburner:info uri="gunnarpeipman" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Sessions I plan to visit at TechDays 2013 Belgium</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/Abhjqb9PL7c/sessions-i-plan-to-visit-at-techdays-2013-belgium.aspx</link><pubDate>Tue, 19 Feb 2013 13:11:14 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9890109</guid><dc:creator>DigiMortal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9890109</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/19/sessions-i-plan-to-visit-at-techdays-2013-belgium.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/Home.aspx"&gt;&lt;img title="TechDays 2013 Belgium" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 10px 10px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="TechDays 2013 Belgium" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/techdays2013_67544DFC.jpg" width="168" height="240" /&gt;&lt;/a&gt;As I’m going to &lt;a href="http://www.microsoft.com/belux/techdays/2013/Home.aspx"&gt;TechDays 2013 Belgium&lt;/a&gt; I made my first plans about sessions I want to visit. It’s always good idea to make some home work before event because it is the only way how to make good decisions. Here is the list of sessions I plan to visit.&lt;/p&gt;  &lt;h3&gt;05.03&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=13"&gt;Deep Dive SharePoint 2013: Brave New World: What SharePoint 2013 Really Means to You&lt;/a&gt; (Dan Holme, level 200) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=69"&gt;Deep Dive SharePoint 2013: Developing applications in SharePoint 2013: forget the past?&lt;/a&gt; (Serge Luca, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=15"&gt;Deep Dive SharePoint 2013: SharePoint app development fundamentals&lt;/a&gt; (Lieven Iliano, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=16"&gt;Deep Dive SharePoint 2013: Accessing SharePoint data&lt;/a&gt; (Lieven Iliano, level 300), &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=17"&gt;Deep Dive SharePoint 2013: SharePoint app security&lt;/a&gt; (Lieven Iliano, level 300) &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;06.03&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=92"&gt;TechDays Developer Keynote&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=20"&gt;Introducing TypeScript&lt;/a&gt; (Bart de Smet, level 200) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=47"&gt;50 Shades of SharePoint: SharePoint 2013 Insanity Demystified&lt;/a&gt; (Dan Holme, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=78"&gt;Putting the Microsoft Design Language to work&lt;/a&gt; (Laurent Bugnion, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=58"&gt;Behind the scenes of (as many) C# language features&lt;/a&gt; (Bart de Smet, level 400) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=8"&gt;Building Scalable and Robust Solutions with Service Bus in Cloud and Server&lt;/a&gt; (Clemens Vasters, level 300) &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;07.03&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=19"&gt;OAuth-as-a-service using ASP.NET Web API and Windows Azure Access Control&lt;/a&gt; (Maarten Balliauw, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=84"&gt;Building Cross Platform Mobile Solutions&lt;/a&gt; (Gitte Vermeiren, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=63"&gt;Coding and designing for Windows 8 and Windows Phone 8, best practices and reusing code&lt;/a&gt; (Laurent Bugnion, level 300) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=64"&gt;Building SPA’s (Single Page App) with Backbone.js&lt;/a&gt; (Richard Griffin, level 400) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2013/SessionDetail.aspx?sessionId=70"&gt;Deep Dive into Entity Framework 6.0&lt;/a&gt; (Diego Vega, level 300) &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9890109" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/Abhjqb9PL7c" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Windows/default.aspx">Windows</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Mobile/default.aspx">Mobile</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Windows+Phone/default.aspx">Windows Phone</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/19/sessions-i-plan-to-visit-at-techdays-2013-belgium.aspx</feedburner:origLink></item><item><title>Four new single page application templates</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/kD3y0pVBo6g/four-new-single-page-application-templates.aspx</link><pubDate>Tue, 19 Feb 2013 00:24:35 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9888313</guid><dc:creator>DigiMortal</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9888313</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/19/four-new-single-page-application-templates.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.hanselman.com/blog/ReleasedASPNETAndWebTools20122InContext.aspx?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+ScottHanselmanASPNET+%28Scott+Hanselman%27s+Computer+Zen+-+ASPNET%29"&gt;ASP.NET and Web Tools 2012.2 are officially out&lt;/a&gt; and although it brings a lot of new stuff to us I want to stop on new Single Page Application templates available by community. I was able to get them all work and now let’s take a look at them.&lt;/p&gt;  &lt;h3&gt;Ember &lt;/h3&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=282647"&gt;Ember&lt;/a&gt; template uses &lt;a href="http://emberjs.com/"&gt;Emberjs&lt;/a&gt; and &lt;a href="http://handlebarsjs.com/"&gt;Handlebars&lt;/a&gt;. It mimics the out-of-box Single Page Application template and therefore it is good to compare these two. Out-of-box template is more lightweight by implementation but Ember is more powerful by features, &lt;a href="http://emberjs.com/guides/understanding-ember/the-view-layer/"&gt;more here&lt;/a&gt;.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Single Page Application: Ember" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Single Page Application: Ember" src="http://weblogs.asp.net/blogs/gunnarpeipman/spa-ember_252616CA.png" width="542" height="388" /&gt;&lt;/p&gt;  &lt;p&gt;Default application looks almost like the one provided out-of-box. I suggest this template to guys who are more familiar with JavaScript because in the case of problems – it seems to me – you need good skills on debugging complex code.&lt;/p&gt;  &lt;h3&gt;Durandal&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=282648"&gt;Durandal template&lt;/a&gt; uses &lt;a href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt; (it’s single page applications framework), &lt;a href="http://twitter.github.com/bootstrap/"&gt;Bootstrap&lt;/a&gt;, &lt;a href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt; and &lt;a href="http://sammyjs.org/"&gt;Sammy&lt;/a&gt;. Their sample application shows you how to show photos from Flickr.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Single Page Application: Durandal" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Single Page Application: Durandal" src="http://weblogs.asp.net/blogs/gunnarpeipman/spa-durandal_7951AEDB.png" width="542" height="319" /&gt;&lt;/p&gt;  &lt;p&gt;Durandal guys make it clear on sample application front page why to go with Durandal:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Clean MV* Architecture&lt;/li&gt;    &lt;li&gt;JS &amp;amp; HTML Modularity&lt;/li&gt;    &lt;li&gt;Simple App Lifecycle&lt;/li&gt;    &lt;li&gt;Eventing, Modals, Message Boxes, etc.&lt;/li&gt;    &lt;li&gt;Navigation &amp;amp; Screen State Management&lt;/li&gt;    &lt;li&gt;Consistent Async Programming w/ Promises&lt;/li&gt;    &lt;li&gt;App Bundling and Optimization&lt;/li&gt;    &lt;li&gt;Use any Backend Technology&lt;/li&gt;    &lt;li&gt;Built on top of jQuery, Knockout &amp;amp; RequireJS&lt;/li&gt;    &lt;li&gt;Integrates with other libraries such as SammyJS &amp;amp; Bootstrap&lt;/li&gt;    &lt;li&gt;Make jQuery &amp;amp; Bootstrap widgets templatable and bindable (or build your own widgets).&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Well, seems like good offer for me. Also their views and model seem simple and seems like there is not very much code writing overhead.&lt;/p&gt;  &lt;h3&gt;Breeze&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=282649"&gt;Breeze template&lt;/a&gt; uses &lt;a href="http://www.breezejs.com/"&gt;Breeze&lt;/a&gt;, &lt;a href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt; and &lt;a href="https://github.com/kriskowal/q/"&gt;q&lt;/a&gt; (a tool for making and composing asynchronous promises in JavaScript). Breeze template is also another implementation of out-of-box ToDo application.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Single Page Application: Breeze" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Single Page Application: Breeze" src="http://weblogs.asp.net/blogs/gunnarpeipman/spa-breeze_259A478E.png" width="542" height="384" /&gt;&lt;/p&gt;  &lt;p&gt;By code Breeze is like a little bit familiar to me. Don’t know why but it reminds me upshot library a little bit. At least the way how server-side and client-side data communication is done is familiar to me. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NB!&lt;/strong&gt; Hopefully it will be fixed soon but when creating project based on this template you may get errors. Don’t be afraid – just add references to Web API OData and tracing and your solution may run with no issues.&lt;/p&gt;  &lt;h3&gt;Hot Towel&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=282646"&gt;Hot Towel template&lt;/a&gt; by &lt;a href="http://www.johnpapa.net/"&gt;John Papa&lt;/a&gt; uses &lt;a href="http://durandaljs.com/"&gt;Durandal&lt;/a&gt;, &lt;a href="http://twitter.github.com/bootstrap/"&gt;Bootstrap&lt;/a&gt;, &lt;a href="http://www.breezejs.com/"&gt;Breeze&lt;/a&gt;, &lt;a href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt;, &lt;a href="https://github.com/kriskowal/q/"&gt;q&lt;/a&gt;, &lt;a href="http://sammyjs.org/"&gt;Sammy&lt;/a&gt; and &lt;a href="https://github.com/CodeSeven/toastr"&gt;Toastr&lt;/a&gt; (simple javascript toast notifications). This template has a lot of scripts with it and some sample code but no samples about how data moves between client and server. &lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Single Page Application: Hot Towel" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Single Page Application: Hot Towel" src="http://weblogs.asp.net/blogs/gunnarpeipman/spa-hot-towel_796D24CF.png" width="542" height="378" /&gt;&lt;/p&gt;  &lt;p&gt;As John Papa states then this template is starting point to get started with building single page applications and I really hope he will add some data access samples too because his template looks very cool.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;It’s good to see these new community templates for SPA-s coming and hopefully growing and getting better too. Good thing is we can build client-side applications that work on (almost) all browsers without worrying about compatibility issues and from the existing selection every interested developer can find the template he likes and start building his application with it.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9888313" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/kD3y0pVBo6g" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/SPA/default.aspx">SPA</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/19/four-new-single-page-application-templates.aspx</feedburner:origLink></item><item><title>Using Microsoft Solver Foundation to solve linear programming tasks</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/odMJBuKCRFs/using-microsoft-solver-foundation-to-solve-linear-programming-tasks.aspx</link><pubDate>Mon, 11 Feb 2013 12:23:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9861534</guid><dc:creator>DigiMortal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9861534</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/11/using-microsoft-solver-foundation-to-solve-linear-programming-tasks.aspx#comments</comments><description>&lt;p&gt;One of soon-to-starts projects uses linear programming for some optimizations. As it is not very familiar topic to me I started looking for examples and tools so I am prepared better when action starts. In this posting I will show you how to solve simple linear programming tasks using &lt;a href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;Microsoft Solver Foundation – free math package available by DevLabs&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Linear programming is used in many real-life calculations: business, economy, transportation, energy, telecommunications, manufacturing etc. The goal is holy: to make optimal decisions and save resources like money, time and materials.&lt;/p&gt;  &lt;h3&gt;Prerequisites&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Some version of Visual Studio &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/devlabs/hh145003.aspx"&gt;Microsoft Solver Foundation&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff524509(v=vs.93).aspx"&gt;Microsoft Solver Foundation documentation&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Big cup of coffee &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;What is linear programming?&lt;/h3&gt;  &lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Linear_programming"&gt;Linear programming&lt;/a&gt; is specific case of mathematical programming or optimization. There is linear function we want to maximize or minimize, there are some constraints and non-negative variables. Practically this is how it goes:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;img title="Feasible region" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Feasible region" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/linear-programming-feasible-area_6FCCA153.png" width="240" height="189" /&gt;We have function to be maximized:       &lt;br /&gt;      &lt;br /&gt;f(x,y) = c&lt;sub&gt;1&lt;/sub&gt;x&lt;sub&gt;1&lt;/sub&gt; + c&lt;sub&gt;2&lt;/sub&gt;x&lt;sub&gt;2&lt;/sub&gt;.       &lt;br /&gt;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;We have constraints like:      &lt;br /&gt;&amp;#160; &lt;br /&gt;a&lt;sub&gt;1&lt;/sub&gt;x&lt;sub&gt;1&lt;/sub&gt; + b&lt;sub&gt;1&lt;/sub&gt;x&lt;sub&gt;2&lt;/sub&gt; &amp;lt;= d&lt;sub&gt;1&lt;/sub&gt;,       &lt;br /&gt;a&lt;sub&gt;2&lt;/sub&gt;x&lt;sub&gt;2&lt;/sub&gt; + b&lt;sub&gt;2&lt;/sub&gt;x&lt;sub&gt;2&lt;/sub&gt; &amp;lt;= d&lt;sub&gt;2.&lt;/sub&gt;       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;Non-negative variables:      &lt;br /&gt;&amp;#160; &lt;br /&gt;x&lt;sub&gt;1&lt;/sub&gt; &amp;gt;= 0,       &lt;br /&gt;x&lt;sub&gt;2&lt;/sub&gt; &amp;gt;= 0. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Based on this information we will find the maximum value. We can do it graphically but we can also calculate the value. On graph above the grey area is called feasible region. Somewhere on the lines that draw this area are points where maximum values are located.&lt;/p&gt;  &lt;h3&gt;Example exercises&lt;/h3&gt;  &lt;p&gt;I found some good linear programming exercises from &lt;a href="http://people.brunel.ac.uk/~mastjjb/jeb/or/morelp.html"&gt;Brunel University home page&lt;/a&gt;.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A company makes two products (X and Y) using two machines (A and B). Each unit of X that is produced requires 50 minutes processing time on machine A and 30 minutes processing time on machine B. Each unit of Y that is produced requires 24 minutes processing time on machine A and 33 minutes processing time on machine B.      &lt;br /&gt;      &lt;br /&gt;At the start of the current week there are 30 units of X and 90 units of Y in stock. Available processing time on machine A is forecast to be 40 hours and on machine B is forecast to be 35 hours.       &lt;br /&gt;      &lt;br /&gt;The demand for X in the current week is forecast to be 75 units and for Y is forecast to be 95 units. Company policy is to maximize the combined sum of the units of X and the units of Y in stock at the end of the week.       &lt;br /&gt;      &lt;br /&gt;Formulate the problem of deciding how much of each product to make in the current week as a linear program. Solve this linear program graphically.       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;A carpenter makes tables and chairs. Each table can be sold for a profit of £30 and each chair for a profit of £10. The carpenter can afford to spend up to 40 hours per week working and takes six hours to make a table and three hours to make a chair. Customer demand requires that he makes at least three times as many chairs as tables. Tables take up four times as much storage space as chairs and there is room for at most four tables each week.      &lt;br /&gt;      &lt;br /&gt;Formulate this problem as a linear programming problem and solve it graphically. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You can find more exercises like this when searching from web.&lt;/p&gt;  &lt;h3&gt;Using Microsoft Solver Foundation&lt;/h3&gt;  &lt;p&gt;Now let’s solve one exercise using Microsoft Solver Foundation. The API it is offering is not very familiar to developers who build usual web applications and it takes some math to understand how and why it is built this way. But still it is not something complex, it’s just a little bit different.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://www.vitutor.com/alg/linear_programming/example_programming.html"&gt;Exercise from Vitutor&lt;/a&gt;. A store has requested a manufacturer to produce pants and sports jackets.&lt;/p&gt;    &lt;p&gt;For materials, the manufacturer has 750 m2 of cotton textile and 1,000 m2 of polyester. Every pair of pants (1 unit) needs 1 m2 of cotton and 2 m2 of polyester. Every jacket needs 1.5 m2 of cotton and 1 m2 of polyester.&lt;/p&gt;    &lt;p&gt;The price of the pants is fixed at $50 and the jacket, $40.&lt;/p&gt;    &lt;p&gt;What is the number of pants and jackets that the manufacturer must give to the stores so that these items obtain a maximum sale?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;First we have to find out what is the function to maximize and what are the constraints. It’s like described above.&lt;/p&gt;  &lt;p&gt;Let’s suppose x = number of pants and y = number of jackets.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Function to maximize:      &lt;br /&gt;      &lt;br /&gt;f(x, y) = 50x + 40y       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;Constraints (check out &lt;a href="http://www.vitutor.com/alg/linear_programming/example_programming.html"&gt;Vitutor page for good explanations&lt;/a&gt;):       &lt;br /&gt;      &lt;br /&gt;2x + 3y &amp;lt;= 1500,       &lt;br /&gt;2x + y &amp;lt;= 1000       &lt;br /&gt;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;Non-negative variables:      &lt;br /&gt;      &lt;br /&gt;x &amp;gt;= 0,       &lt;br /&gt;y &amp;gt;= 0. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now we have all information in place based on what we know and it’s time to write some code.&lt;/p&gt;  &lt;p&gt;We create Windows console application and create reference to &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.services(v=vs.93).aspx"&gt;Microsoft.SolverFoundation.Services&lt;/a&gt; assembly that is located in the following place on your hard disk:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Solver.Foundation.dll&lt;/p&gt; &lt;/blockquote&gt; &lt;span style="color: "&gt;   &lt;pre style="font-family: ; background: white; line-height: normal"&gt;&lt;hr size="1" /&gt;&lt;/pre&gt;

  &lt;pre style="font-family: ; background: white; line-height: normal"&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;using&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Microsoft.SolverFoundation.Services;&lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; System; &lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; System.Linq;&lt;br /&gt;   &lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;namespace&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; LinearProgrammingSFS &lt;br /&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Program&lt;br /&gt;&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;static&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Main(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;[] args)&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Create solver context and model&lt;br /&gt;&lt;/font&gt;&lt;/span&gt; &lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;SolverContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; context = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;SolverContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.GetContext();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Model&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; model = context.CreateModel();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Create decision for objective function&lt;br /&gt;&lt;/font&gt;&lt;/span&gt; &lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Decision&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; x = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Decision&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Domain&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.RealNonnegative, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;pants&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Decision&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; y = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Decision&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Domain&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.RealNonnegative, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;jackets&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.AddDecisions(x, y);&lt;br /&gt;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Add constraints&lt;br /&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.AddConstraints(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;production&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 * x + 3 * y &amp;lt;= 1500,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 * x + y &amp;lt;= 1000);&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Add non-negative variables&lt;br /&gt;&lt;/font&gt;&lt;/span&gt; &lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.AddConstraints(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;nonnegative&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; x &amp;gt;= 0,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; y &amp;gt;= 0);&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Add goal - what we want to maximize&lt;br /&gt;&lt;/font&gt;&lt;/span&gt; &lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.AddGoal(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;cost&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;GoalKind&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Maximize,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 50 * x + 40 * y);&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Solution&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; solution = context.Solve(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;SimplexDirective&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;());&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Report&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; report = solution.GetReport();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Console&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.WriteLine(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;result: &amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; + solution.Goals.First().ToDouble());&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Console&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.WriteLine(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;x: {0}, y: {1}&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, x.ToDouble(), y.ToDouble());&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Console&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Write(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;{0}&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;, report);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Console&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.ReadLine();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }
}
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;hr size="1" /&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;p&gt;If we run this program we will get the following output:&lt;/p&gt;

  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/linear-programming-solution_279EE577.png"&gt;&lt;img title="Output of Microsoft Solver Foundation" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Output of Microsoft Solver Foundation" src="http://weblogs.asp.net/blogs/gunnarpeipman/linear-programming-solution_thumb_3F561CDD.png" width="540" height="417" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;The first two lines in output give us solution: manufacturer has to make 375 pants and 250 jackets to earn $28.750 that is maximally possible. All the other output is Solver Foundation report about calculation made. &lt;/p&gt;

  &lt;h3&gt;Conclusion&lt;/h3&gt;

  &lt;p&gt;Microsoft Solver Foundation is set of math tools that allows you to solve some mathematical problems you face in real-world applications. Although the API it provides is not very similar to what many of us have seen before it is still simple enough to get started with it when math side is clear. In this posting we solved simple linear programming task. When we got preparation work done we wrote some simple lines of code to get answers we were looking for. Microsoft Solver Foundation is wider platform for different calculations and before writing math manually I suggest you to take a look at what Solver Foundation has to offer.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9861534" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/odMJBuKCRFs" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Solver+Foundation/default.aspx">Solver Foundation</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/11/using-microsoft-solver-foundation-to-solve-linear-programming-tasks.aspx</feedburner:origLink></item><item><title>Let’s go to TechDays 2013 Belgium!</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/Eel7I51tpys/let-s-go-to-techdays-2013-belgium.aspx</link><pubDate>Fri, 08 Feb 2013 11:19:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9851866</guid><dc:creator>DigiMortal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9851866</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/08/let-s-go-to-techdays-2013-belgium.aspx#comments</comments><description>&lt;p&gt;Last autumn I found some very good presentations from Channel9 and they all were made during TechDays 2012 Netherlands and Belgium. One of those sessions was even so useful that I made some updates to my community presentations I worked on. This year I will visit &lt;a href="http://www.microsoft.com/belux/techdays/2012/Home.aspx"&gt;&lt;strong&gt;TechDays 2013 Belgium&lt;/strong&gt;&lt;/a&gt; to get better idea what is and see who’s there. Who knows, maybe I can find some new friends from Belgium. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/belux/techdays/2012/Home.aspx"&gt;&lt;img title="TechDays 2013 Belgium" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 0px 10px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="TechDays 2013 Belgium" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/techdayslogo_side_24C54470.png" width="150" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;What is coming?&lt;/h3&gt;  &lt;p&gt;To concentrate all things to short list here’s what’s coming:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;one day of active training about SharePoint, Visual Studio Application Life-Cycle, Exchange and security,&lt;/li&gt;    &lt;li&gt;two days of sessions about Winodws 8, Visual Studio, Windows Server 2012, Windows Azure, System Center, Exchange 2013, Office 2013, Windows Phone and more,&lt;/li&gt;    &lt;li&gt;speakers like Clemens Vasters, Bart de Smet, Jeff Prosise, Corey Hynes, John Craddock, Kurt Roggen, Dan Holme, Paula Januzskiewicz, Laurent Bugnion, Maarten Balliauw,&lt;/li&gt;    &lt;li&gt;networking – good option to make contacts with fellow developers and IT-PROs.&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;When and where it happens?&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;05-07.03.2012 @ Kinepolis Antwerp&lt;/strong&gt;. Antwerp is nice small city in northern part of Belgium. It’s easy to get there from near-by countries and guys who don’t live near can take flight to Brussels or Eindhoven and come with train (like I do). Kinepolis Antwerp is about 4km away from Antwerp central railway station and other popular areas. So if you take hotel near railway station then you can go with public transportation – it’s not a long distance.&lt;/p&gt;  &lt;h3&gt;Why Belgium is cool?&lt;/h3&gt;  &lt;p&gt;Well… Belgium and also Netherlands are cute countries with nice towns and friendly people. For me these countries are relaxing as in my country people are always in hurry and stressed and pretty much closed. There it’s different and it fits better with my nature. Also weather there is milder than in north.&lt;/p&gt;  &lt;h4&gt;Special beers&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://www.vanhonsebrouck.be/"&gt;&lt;img title="Kasteel Rouge" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 0px 10px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Kasteel Rouge" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/kasteel-rouge_22A845A7.jpg" width="168" height="190" /&gt;&lt;/a&gt;And here’s more – beer and food! Take a look at this dark red beauty on this image. Yes, it’s cherry beer and no, it’s not done “like usually”. This one is made using high quality cherry liquor – it’s so damn good that I even buy it with damn high price here in Estonia. &lt;/p&gt;  &lt;p&gt;There are more special beers like this – just take some cozy pub with big selection and enjoy. These beers are often strong ones but consequences in morning are not awful like with most beers in this world.&lt;/p&gt;  &lt;p&gt;Anyway, our days there are spent in conference and evenings are free, so …. :)&lt;/p&gt;  &lt;h3&gt;Why I go there?&lt;/h3&gt;  &lt;p&gt;I go there as the materials of TechDays Belgium for previous years have been very good. When I find some event with good sessions and speakers then I go there for sure. Also TechDays is not extremely expensive. Two days of conference and one day of training is around 600EUR per person. Add there nice small town, nice people, cute small shops and damn good beers – what else you may want?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9851866" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/Eel7I51tpys" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Exchange+Server/default.aspx">Exchange Server</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Azure/default.aspx">Azure</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Community+news/default.aspx">Community news</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Windows+Phone/default.aspx">Windows Phone</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/08/let-s-go-to-techdays-2013-belgium.aspx</feedburner:origLink></item><item><title>Using database unit tests in Visual Studio</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/_WAIMuoTeK4/using-database-unit-tests-in-visual-studio.aspx</link><pubDate>Thu, 07 Feb 2013 07:23:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9848187</guid><dc:creator>DigiMortal</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9848187</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/07/using-database-unit-tests-in-visual-studio.aspx#comments</comments><description>&lt;p&gt;Stored procedures in SQL Server database can be unit tested using Visual Studio database unit tests. It may seem as simple thing to do at first but when you start writing tests then you will find out it’s more complex task to do then expected. In this posting I will introduce database testing with Visual Studio tools.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;NB!&lt;/strong&gt; In this posting I will use Visual Studio 2010 as I was not able to make database unit tests run on Visual Studio 2012. VS2012 has also these tests available but it seems to me that this support is still raw and waits for stabilization and fixes.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Are they actually unit tests?&lt;/h3&gt;  &lt;p&gt;I am not very sure that these tests can be called unit tests. They are different than unit tests we are used from applications development. As these tests may also test integrated components in database I would rather call these tests as database tests. Considering these tests to be wider than unit tests is okay because same mechanism allows us write very different tests for databases.&lt;/p&gt;  &lt;h3&gt;Why database testing?&lt;/h3&gt;  &lt;p&gt;Databases are often more complex beasts than just some tables, keys and indexes. Often databases contain complex queries, stored procedures and user-defined functions. SQL Server has also support for CLR libraries. All these database objects contain some logic that is usually very important. &lt;/p&gt;  &lt;p&gt;Systems that make heavy use of stored procedures are good targets for database tests. Actually there are two ways how to test these databases:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;regular integration tests against some service or set of classes that make data available to system, &lt;/li&gt;    &lt;li&gt;database tests. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Database tests seems better option to me because then we don’t include code from other layers to tests and therefore bugs in other layers cannot affect the results of database tests.&lt;/p&gt;  &lt;h3&gt;Testing user defined function&lt;/h3&gt;  &lt;p&gt;Let’s start with simple test that can be considered as unit test. Here is the definition of our function:&lt;/p&gt;  &lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.8pt"&gt;CREATE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;FUNCTION&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; [dbo]&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;[GetImportantValue]&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;	@n &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;RETURNS&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;float&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;AS&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;	&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#ff00ff"&gt;ABS&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;@n&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;)=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;2&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;	&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;begin&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;		&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt; 0
	&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;end&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;	&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; 1.0 &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;4 &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;-&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; @n&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;*&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;@n&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.8pt" color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;hr size="1" /&gt;&lt;/pre&gt;

&lt;p&gt;What can be tested here? Couple of things:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;does the function give expected results with normal values? &lt;/li&gt;

  &lt;li&gt;does the function give expected results with special values? &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okay, what’s normal and what’s special value? Normal values are the one that function is expected to accept in all usual cases. Special values in current case are values that cause division by zero. We don’t want to find errors like this in public test or production environments.&lt;/p&gt;

&lt;h3&gt;Creating database test&lt;/h3&gt;

&lt;p&gt;We start with creating new test project in Visual Studio and adding database unit test to this project.&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-add_7EEAF729.png"&gt;&lt;img title="Add new database unit test" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Add new database unit test" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-add_thumb_1C7CD229.png" width="540" height="450" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After project is created we have there one default unit test and we must remove it as we don’t need it. If we run it we get exception and there is always one failed test in our tests list.&lt;/p&gt;

&lt;p&gt;Now let’s add database unit test. Our first test is just call to our function with value 3.&lt;/p&gt;

&lt;p align="center"&gt;&lt;img title="Simple database unit test body" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Simple database unit test body" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-simple_4630274F.png" width="540" height="400" /&gt;&lt;/p&gt;

&lt;p&gt;We remove default test condition. Instead of it we will add Scalar value condition as we expect back scalar value. Clicking on condition we can set expected value.&lt;/p&gt;

&lt;p align="center"&gt;&lt;img title="Setting properties for scalar valued test condition" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Setting properties for scalar valued test condition" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-scalar-condition_2F413006.png" width="540" height="400" /&gt;&lt;/p&gt;

&lt;p&gt;Now the first test is ready. &lt;/p&gt;

&lt;h3&gt;Running test&lt;/h3&gt;

&lt;p&gt;Build project and from top menu select Test =&amp;gt; Run =&amp;gt; All Tests in Solution. Npw all tests in current solution are run and results are shown in test results Windows.&lt;/p&gt;

&lt;p align="center"&gt;&lt;img title="Database unit test result" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Database unit test result" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-simple-result_663B0E3F.png" width="540" height="173" /&gt;&lt;/p&gt;

&lt;p&gt;Our test passed and everything this far is okay.&lt;/p&gt;

&lt;h3&gt;Adding more conditions&lt;/h3&gt;

&lt;p&gt;We had more than one value to test our function. We can add more tests to our test project but we can also use same test with more than one test condition.&lt;/p&gt;

&lt;p&gt;Let’s add tests for these values: –3, –2, 0, 2, 3. As first thing we will modify our test query. As it has to return only five numbers we can add scalar value conditions for these numbers without making test too complex to handle.&lt;/p&gt;

&lt;p align="center"&gt;&lt;img title="More complex database unit test" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="More complex database unit test" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-multiple-values_24C05BE6.png" width="534" height="429" /&gt;&lt;/p&gt;

&lt;p&gt;Here is one trick with test conditions. We have to change also column index of each scalar condition as our test will return one row with five columns. Running the test we get the following result.&lt;/p&gt;

&lt;p align="center"&gt;&lt;img title="Result of more complex database unit test" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Result of more complex database unit test" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2010-database-unit-test-simple-result_0A7FF2C2.png" width="540" height="173" /&gt;&lt;/p&gt;

&lt;p&gt;Visual Studio database tests let us actually do much more but this posting is long enough and I will come back to database tests some other time.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;





&lt;p&gt;Database unit tests are power tool to use when building database that implements some business logic or performs sensitive calculations and we want to be sure that code in database works correctly. There are many ways how database tests can be written and here we started with simple case that gets you going. Database tests have much more to offer and I suggest you to try them out. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9848187" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/_WAIMuoTeK4" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Testing/default.aspx">Testing</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Databases/default.aspx">Databases</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/07/using-database-unit-tests-in-visual-studio.aspx</feedburner:origLink></item><item><title>Bundling and minifying in ASP.NET MVC</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/9U-LLzW8H7Q/bundling-and-minifying-in-asp-net-mvc.aspx</link><pubDate>Wed, 06 Feb 2013 09:04:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9844760</guid><dc:creator>DigiMortal</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9844760</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/06/bundling-and-minifying-in-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;Bundling and minifying in ASP.NET is powerful feature that helps you to optimize your web sites and save some expenses on traffic. As any other machinery in this world, bundling and minifying is not silver bullet and it has it’s own limitations. In this posting I will show you how bundling and minifying works in ASP.NET MVC.&lt;/p&gt;  &lt;h3&gt;What is bundling and minifying?&lt;/h3&gt;  &lt;p&gt;Bundling helps you to download files of same type using one request instead of multiple requests. This way you can download styles and scripts using less requests than it takes to request all files separately. Minifying helps you make files smaller by removing unnecessary whitespace. &lt;/p&gt;  &lt;p&gt;Together these two lessen the amount of requests and bytes to get page loaded by browser. &lt;/p&gt;  &lt;h3&gt;How bundling and minifying works in ASP.NET MVC&lt;/h3&gt;  &lt;p&gt;In ASP.NET MVC 4 web application you can find BundleConfig.cs file under App_Start folder. This file contains BundleConfig class that has only one method – RegisterBundles(). In this method files that must be downloaded with one request are added to bundles. &lt;/p&gt;  &lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.8pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;static&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; RegisterBundles(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;BundleCollection&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; bundles)
{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ScriptBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/jquery&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/jquery-{version}.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;));&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ScriptBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/jqueryui&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/jquery-ui-{version}.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;));&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ScriptBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/jqueryval&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/jquery.unobtrusive*&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/jquery.validate*&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;));&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Use the development version of Modernizr to develop with and learn from.&lt;br /&gt;    // Then, when you're &lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;ready for production, use the build tool at &lt;br /&gt;    //http://modernizr.com to pick only the tests you need.&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ScriptBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/modernizr&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/modernizr-*&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;));&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StyleBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;).Include(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/site.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;));&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; &lt;br /&gt;    bundles.Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StyleBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.core.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.resizable.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.selectable.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.accordion.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.autocomplete.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.button.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.dialog.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.slider.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.tabs.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.datepicker.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.progressbar.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/jquery.ui.theme.css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;));
}
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;hr size="1" /&gt;

&lt;p&gt;Here all files in each bundle are concatenated together and downloaded as one file. It means that this method defines the following URL-s to download files:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;~/bundles/jquery &lt;/li&gt;

  &lt;li&gt;~/bundles/jqueryui &lt;/li&gt;

  &lt;li&gt;~/bundles/jqueryval &lt;/li&gt;

  &lt;li&gt;~/bundles/modernizr &lt;/li&gt;

  &lt;li&gt;~/Content/css &lt;/li&gt;

  &lt;li&gt;~/Content/themes/base/css &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take a good look at file definitions. You can see that you can specify files not only by name but also by name pattern. Special placeholder {version} in file name means that file name may contain version number. This name pattern is specially good for jQuery that is updated often. When you replace your old jQuery file that has version number in its name with newer version then you don’t have to rename the file. It is enough when file has different version number in its name.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;NB!&lt;/strong&gt; In debug-mode bundling is switched off by default. To force bundling in debug-mode add the following line in the beginning of RegisterBundles() method:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;&lt;font style="font-size: 9.8pt"&gt;BundleTable&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;.EnableOptimizations = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;true&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

  &lt;hr size="1" /&gt;&lt;/blockquote&gt;

&lt;p&gt;If you open _Layout.cs view of your application you can see how style and script bundles are included to page:&lt;/p&gt;

&lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;&lt;font style="font-size: 9.8pt"&gt;@&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Styles&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Render(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;) 
      &lt;br /&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Scripts&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Render(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/modernizr&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;) 
      &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;&lt;font style="font-size: 9.8pt"&gt;@&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Scripts&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Render(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/jquery&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&amp;#160; &lt;hr size="1" /&gt;

&lt;p&gt;Although we have more bundles defined these are there for using with pages where they are actually needed.&lt;/p&gt;

&lt;h3&gt;ScriptBundle and StyleBundle&lt;/h3&gt;

&lt;p&gt;If you noticed then script bundle and style bundle have different classes. &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.optimization.scriptbundle.aspx"&gt;ScriptBundle&lt;/a&gt; is targeted to scripts and you shouldn’t add any other files to script bundles. Same with styles goes for &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.optimization.stylebundle.aspx"&gt;StyleBundle&lt;/a&gt;. Both of these classes extend general &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.optimization.bundle.aspx"&gt;Bundle&lt;/a&gt; class that offers bundling functionality. &lt;/p&gt;

&lt;p&gt;Taking care of minifying is tricky. Neither of these classes have no functionality like this. All they do is they add correct minifier to their transforms collection. There are two minifying classes defined in &lt;a href="http://msdn.microsoft.com/en-us/library/hh195125.aspx"&gt;System.Web.Optimizations&lt;/a&gt; namespace:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.optimization.jsminify.aspx"&gt;JsMinify&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.optimization.cssminify.aspx"&gt;CssMinify&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the classes that make the actual work. Same way can everybody write minification transforms one needs and if it is desired to keep same style as built-in bundles then one can create new bundle class that adds custom minifier to transforms collection when new bundle is created.&lt;/p&gt;

&lt;h3&gt;Switching off minifying&lt;/h3&gt;

&lt;p&gt;Yesterday I found out that CssMinify gets stuck with some style files. In the case of problems bundlers write problems out as comments to file they are transforming. Problems are reported in the beginning of file. While developers try to find out what is wrong with those style files we cannot keep minifying turned on for styles but we still want bundling to work.&lt;/p&gt;

&lt;p&gt;There are two ways how to do it.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Use Bundle class.&lt;/strong&gt; Bundle class that other bundling classes extend is not abstract class. We can create instance of it. This way we can bundle whatever files we want. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Clear transforms collection of StyleBundle.&lt;/strong&gt; Clearing transforms collection is same as using Bundle class with empty transforms collection. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Tips and tricks&lt;/h3&gt;

&lt;p&gt;Here are some tips and tricks related to bundling.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Bundles are cached.&lt;/strong&gt; If not specified differently in bundle class then bundle is created on first request and cached on server. All following requests for bundles are served from cache.&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Always test bundling.&lt;/strong&gt; Bundling may seems like what-can-go-wrong feature. You just turn it on before deploying your system to production. But don’t forget these to transform classes I introduced. These classes may face unexpected situations they are not able to handle. Before deploying your system to production make sure that bundling and minifying works like expected.&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Be careful with styles. &lt;/strong&gt;When bundling style sheets make sure that bundle path is same “deep” as style sheet path. If style sheet refers to images or other styles using relative URL-s and you change depth of path then all these references are broken.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Bundling and minifying is powerful feature that helps us optimize our web pages. Bundles are easy to use and they are supported out-of-box. Actually almost all ASP.NET MVC templates use bundles. Thanks to easy and flexible API we can control almost every aspect of bundling. Also we can create our own custom bundle types and define custom transforms that are applied to files in bundles. Although bundling is very good it has its own limits and tricks you must know to use them successfully. Good thing is – there are only few things that can go wrong.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9844760" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/9U-LLzW8H7Q" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Web+development/default.aspx">Web development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/MVC/default.aspx">MVC</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/06/bundling-and-minifying-in-asp-net-mvc.aspx</feedburner:origLink></item><item><title>Moving ASP.NET Single Page Application to TypeScript</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/NbfqwquJS-I/moving-asp-net-single-page-application-to-typescript.aspx</link><pubDate>Tue, 05 Feb 2013 00:14:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9839468</guid><dc:creator>DigiMortal</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9839468</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/05/moving-asp-net-single-page-application-to-typescript.aspx#comments</comments><description>&lt;p&gt;I just moved ASP.NET Single Page Application out-of-box example to &lt;a href="http://www.typescriptlang.org/"&gt;TypeScript&lt;/a&gt;. My idea was to try out how TypeScript works and what it means to move existing JavaScript application to it. Here is overview about what I did and what was my experience with my first steps on TypeScript.&lt;/p&gt;  &lt;h3&gt;Prerequisites&lt;/h3&gt;  &lt;p&gt;You need the following pieces of software installed on your machine to use my code:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=275131"&gt;ASP.NET and Web Tools 2012.2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=34790"&gt;TypeScript for Visual Studio 2012&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/downloads/AspNetSpaTypeScript.zip"&gt;My ASP.NET SPA TypeScript application&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;What is TypeScript?&lt;/h3&gt;  &lt;p&gt;TypeScript is superset of JavaScript that is targeted to building large JavaScript application. It supports type hinting, modules and variable scopes. It is not separate language – every JavaScript application is TypeScript application and vice versa. &lt;/p&gt;  &lt;p&gt;TypeScript files are “compiled” to JavaScript when you build your application and all rules given in TypeScript files are checked. Errors are shown as usual compile errors that stop the building process. It is easy to avoid mistakes this way that otherwise maybe hard to find.&lt;/p&gt;  &lt;p&gt;TypeScript has more familiar object-oriented syntax but it doesn’t do any magic. It is close to JavaScript and to write it one must know how JavaScript works.&lt;/p&gt;  &lt;h3&gt;ASP.NET SPA default application&lt;/h3&gt;  &lt;p&gt;&lt;img title="ASP.NET Single Page Application JavaScript files" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 0px 10px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="ASP.NET Single Page Application JavaScript files" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/aspnet-spa-2012-2-js-files_35DC1153.png" width="244" height="459" /&gt;When you create new &lt;a href="http://weblogs.asp.net/gunnarpeipman/archive/2013/01/28/new-asp-net-single-page-application-template.aspx"&gt;ASP.NET Single Page Application project&lt;/a&gt; it has some files already there that make up the sample application. &lt;/p&gt;  &lt;p&gt;Besides Web API controllers that are used to move data between user interface and server there are some JavaScript files under Scripts folder:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;todo.binding.js&lt;/strong&gt; – additional &lt;a href="http://weblogs.asp.net/gunnarpeipman/archive/2013/01/27/my-experiences-with-knockout.aspx"&gt;Knockout&lt;/a&gt; bindings for sample application (clearing textbox when user clicks enter, placeholder text functionality for non-HTML5 browsers etc),       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;todo.datacontext.js&lt;/strong&gt; – one-class-data-layer that coordinates all data operations,       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;todo.model.js&lt;/strong&gt; – model for sample application, contains classes used by sample application (take these classes as models and not as browser-side version of domain classes),       &lt;br /&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;todo.viewmodel.js&lt;/strong&gt; – view model for sample application. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Some things I don’t like about these files is the fact that each of these files contains one large function that has classes defined inside it. I would like if code is written more object-oriented way and I don’t keep have to keep in mind the fact that these files are actually one big JavaScript calls.&lt;/p&gt;  &lt;h3&gt;Moving to TypeScript&lt;/h3&gt;  &lt;p&gt;I moved JavaScript files mentioned above to TypeScript. The only exception was bindings file as it was simple and straight-forward enough. For other files I made the following steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;create new TypeScript files (I prefer one class per file style), &lt;/li&gt;    &lt;li&gt;add module definition, &lt;/li&gt;    &lt;li&gt;port code from current file to TypeScript class, &lt;/li&gt;    &lt;li&gt;make sure all code that is not part of JavaScript class gets called, &lt;/li&gt;    &lt;li&gt;add new file to JavaScripts bundle, &lt;/li&gt;    &lt;li&gt;uncomment code in old file, &lt;/li&gt;    &lt;li&gt;run application and test. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There are some things I made differently:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;there is one class per TypeScript file, &lt;/li&gt;    &lt;li&gt;I added special Application.ts file that contains application initialization code. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I like when class files are clean and doesn’t contain code that starts doing something when loaded. If all initialization code is in same file (Application.ts in my case) then it makes me easier to control how application is initialized and started.&lt;/p&gt;  &lt;h3&gt;Example class&lt;/h3&gt;  &lt;p&gt;As an example of TypeScript class let’s take TodoItem.ts from my application:&lt;/p&gt;  &lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;hr size="1" /&gt;&lt;span style="color: "&gt;&lt;font color="#008000" face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;/// &amp;lt;reference path=&amp;quot;DataContext.ts&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;
&lt;font color="#0000ff" face="Consolas"&gt; 
declare&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; ko;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;
&lt;font color="#0000ff" face="Consolas"&gt;declare&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; todoApp;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;
&lt;font color="#0000ff" face="Consolas"&gt; 
module&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; TodoApp {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;export&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; TodoItem {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; datacontext: TodoApp.DataContext;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TodoItemId: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;any&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Title: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;any&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IsDone: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;any&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TodoListId: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;any&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; ErrorMessage: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;any&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; save;&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;constructor&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;(data, datacontext: TodoApp.DataContext) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.datacontext = datacontext;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data = data || {};&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Persisted properties&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.TodoItemId = data.TodoItemId;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Title = ko.observable(data.Title);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.IsDone = ko.observable(data.IsDone);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.TodoListId = data.TodoListId;&lt;br /&gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Non-persisted properties&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.ErrorMessage = ko.observable();&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; _self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.save = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; todoApp.datacontext.saveChangedTodoItem(_self);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;// Auto-save when these properties change&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.IsDone.subscribe(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;.save);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Title.subscribe(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.save);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }
}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;hr size="1" /&gt;&lt;/pre&gt;

&lt;p&gt;And this is the JavaScript that is generated from TypeScript above:&lt;/p&gt;

&lt;hr size="1" /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; TodoApp; 
      &lt;br /&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (TodoApp) { 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; TodoItem = (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; TodoItem(data, datacontext) { 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.datacontext = datacontext; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data = data || {}; 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.TodoItemId = data.TodoItemId; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Title = ko.observable(data.Title); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.IsDone = ko.observable(data.IsDone); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.TodoListId = data.TodoListId; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.ErrorMessage = ko.observable(); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; _self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.save = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; todoApp.datacontext.saveChangedTodoItem(_self); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }; 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.IsDone.subscribe(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.save); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Title.subscribe(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;.save); 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; TodoItem; 
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })(); 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TodoApp.TodoItem = TodoItem; 

      &lt;br /&gt;})(TodoApp || (TodoApp = {})); 

      &lt;hr size="1" /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;

&lt;p&gt;One thing is miss is some good way to write object-oriented code without using typical self-closure hack to refer to class instance safely in methods. &lt;/p&gt;

&lt;h3&gt;Configuring bundling&lt;/h3&gt;

&lt;p&gt;Although your TypeScript files are not downloaded to browser when page loads you have to load JavaScript files that were generated by TypeScript. I’m doing the loading of these files in bundling configuration of my web application. It’s done in BundleConfig.cs file under App_Start folder.&lt;/p&gt;

&lt;hr size="1" /&gt; &lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 9.8pt"&gt;bundles.Add(&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ScriptBundle&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/bundles/todo&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).Include(
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/todo.bindings.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/DataContext.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/TodoItem.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/TodoList.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/TodoListViewModel.js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;,
      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/app/Application.js&amp;quot;&lt;/font&gt;&lt;/span&gt;

    &lt;br /&gt;&lt;font color="#000000"&gt;));
      &lt;hr size="1" /&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;

&lt;p&gt;JavaScript files generated by TypeScript are in same folder with TypeScript files and they have same name as TypeScript files.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;TypeScript is cool thing and I think it’s very good fit for large JavaScript applications as it helps to detect places in code where things are not used the way that was expected. As TypeScript is superset of JavaScript it is easy to convert between those two and also language rules are almost the same. It wasn’t very hard to convert SPA default application JavaScript to TypeScript and I am sure that over next years we will see JavaScript projects that make heavy use of TypeScript.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9839468" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/NbfqwquJS-I" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Web+development/default.aspx">Web development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/02/05/moving-asp-net-single-page-application-to-typescript.aspx</feedburner:origLink></item><item><title>Using jQuery webcam plugin with ASP.NET MVC</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/RUusQpueWS0/using-jquery-webcam-plugin-with-asp-net-mvc.aspx</link><pubDate>Wed, 30 Jan 2013 18:50:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9817362</guid><dc:creator>DigiMortal</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9817362</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/30/using-jquery-webcam-plugin-with-asp-net-mvc.aspx#comments</comments><description>&lt;p&gt;I have to use webcam images in one of applications I build and when playing with different components I found free and easy to use Flash and jQuery based webcam component called &lt;a href="http://www.xarg.org/project/jquery-webcam-plugin/"&gt;jQuery webcam plugin&lt;/a&gt;. In this posting I will show you how to use jQuery webcam plugin with ASP.NET MVC application to save captured image to server hard disc.&lt;/p&gt; &lt;h3&gt;Preparation&lt;/h3&gt; &lt;p&gt;Here are some steps to take before writing any ASP.NET code:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Create new ASP.NET MVC application.  &lt;li&gt;Download jQuery webcam plugin and extract it.  &lt;li&gt;Put jquery.webcam.js, jscam.swf and jscam_canvas_only.swf files to Scripts folder of web application. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Now we are ready to go.&lt;/p&gt; &lt;h3&gt;Create webcam page&lt;/h3&gt; &lt;p&gt;We start with creating default page of web application. I’m using Index view of Home controller.&lt;/p&gt; &lt;hr size="1"&gt; &lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font style="font-size: 9.8pt"&gt;@{&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ViewBag.Title = &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"Index"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000" face="Consolas"&gt;;&lt;br&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@section scripts&lt;br&gt;{&lt;br&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;"&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Url.Content(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"~/Scripts/jquery.webcam.js"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;"&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#000000"&gt;$(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"#Camera"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).webcam({&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; width: 320,&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; height: 240,&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; mode: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"save"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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; swffile: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Url.Content(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"~/Scripts/jscam.swf"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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; onTick: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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; onSave: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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;&amp;nbsp;&amp;nbsp; onCapture: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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; webcam.save(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Url.Content(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"~/Home/Capture"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;/"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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;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; debug: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&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; onLoad: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { }&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; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;&lt;span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h2&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Index&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h2&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;input&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;"button"&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;value&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;"Shoot!"&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;onclick&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;"&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;webcam.capture();&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;"&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;"Camera"&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.8pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;hr size="1"&gt;&lt;/pre&gt;&lt;pre style="font-family: ; background: white; color: ; line-height: normal"&gt;&lt;/pre&gt;
&lt;p&gt;We initialize webcam plugin in additional scripts block offered by layout view. To send webcam capture to server we have to use webcam plugin in save mode. onCapture event is the one where we actually give command to send captured image to server. Button with value “Shoot!” is the one we click at right moment.&lt;/p&gt;
&lt;h3&gt;Saving image to server hard disk&lt;/h3&gt;
&lt;p&gt;Now let’s save captured image to server hard disk. We add new action called Capture to Home controller. This action reads image from input stream, converts it from hex dump to byte array and then saves the result to disk.&lt;/p&gt;
&lt;p&gt;Credits for String_To_Bytes2() method that I quickly borrowed go to Kenneth Scott and his blog posting &lt;a href="http://programmerramblings.blogspot.com/2008/03/convert-hex-string-to-byte-array-and.html"&gt;Convert Hex String to Byte Array and Vice-Versa&lt;/a&gt;.&lt;/p&gt;
&lt;hr size="1"&gt;
&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.8pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;HomeController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Controller&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Index()&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;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; View();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Capture()&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;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; stream = Request.InputStream;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; dump;&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; reader = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StreamReader&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;(stream))&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; dump = reader.ReadToEnd();&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; path = Server.MapPath(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;"~/test.jpg"&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.IO.&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;File&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.WriteAllBytes(path, String_To_Bytes2(dump));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;byte&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;[] String_To_Bytes2(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; strInput)&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;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; numBytes = (strInput.Length) / 2;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;byte&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;[] bytes = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;byte&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;[numBytes];&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; x = 0; x &amp;lt; numBytes; ++x)&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bytes[x] = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Convert&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;.ToByte(strInput.Substring(x * 2, 2), 16);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; bytes;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;} 
&lt;hr size="1"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;Before running the code make sure you can write files to disk. Otherwise nasty access denied errors will come.&lt;/p&gt;
&lt;h3&gt;Testing application&lt;/h3&gt;
&lt;p&gt;Now let’s run the application and see what happens.&lt;/p&gt;
&lt;p align="center"&gt;&lt;img title="jQuery webcam plugin: Flash needs permissions to use webcam" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="jQuery webcam plugin: Flash needs permissions to use webcam" src="http://weblogs.asp.net/blogs/gunnarpeipman/jquery-webcam-allow-flash_4EE0B85A.png" width="337" height="336"&gt;&lt;/p&gt;
&lt;p&gt;Whoops… we have to give permission to use webcam and microphone to Flash before we can use webcam. Okay, it is for our security.&lt;/p&gt;
&lt;p&gt;After clicking Allow I was able to see picture that was forgot to protect with security message.&lt;/p&gt;
&lt;p align="center"&gt;&lt;img title="jQuery webcam plugin: Me in webcam" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="jQuery webcam plugin: Me in webcam" src="http://weblogs.asp.net/blogs/gunnarpeipman/jquery-webcam-image_5FE4E63D.png" width="342" height="341"&gt;&lt;/p&gt;
&lt;p&gt;This tired hacker in dark room is actually me, so it seems like JQuery webcam plugin works okay :)&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;jQuery webcam plugin is simple and easy to use plugin that brings basic webcam functionalities to your web application. It was pretty easy to get it working and to get image from webcam to server hard disk. On ASP.NET side we needed simple hex dump conversion to make hex dump sent by webcam plugin to byte array before saving it as JPG-file.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9817362" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/RUusQpueWS0" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Web+development/default.aspx">Web development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/30/using-jquery-webcam-plugin-with-asp-net-mvc.aspx</feedburner:origLink></item><item><title>How to make NLog create separate log per service thread</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/fRO_dSeR5RA/how-to-make-nlog-create-separate-log-per-service-thread.aspx</link><pubDate>Wed, 30 Jan 2013 06:51:25 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9815565</guid><dc:creator>DigiMortal</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9815565</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/30/how-to-make-nlog-create-separate-log-per-service-thread.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://nlog-project.org/"&gt;NLog&lt;/a&gt; on is popular logging component for .NET applications. I am using it in one project where I built multi-threaded server that is running similar threads with different configuration. As those thread are independent services I needed way how to configure NLog to create different log file for each thread. Here is my solution.&lt;/p&gt;  &lt;p&gt;&lt;img title="Server instances structure in file system" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 5px 10px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Server instances structure in file system" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/server-instance-log_2EC89948.png" width="104" height="85" /&gt;When new service starts in its thread I will configure NLog in code to create log file to correct folder with correct name and layout. Image on right shows how server is keeping instances data on disk. Each instance has its own folder and for logs there is subfolder because for every date there will be new log file.&lt;/p&gt;  &lt;hr size="1" /&gt;  &lt;div style="font-family: ; background: white; color: "&gt;   &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 10pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 10pt"&gt; target = &lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;FileTarget&lt;/font&gt;&lt;/span&gt;();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;target.Name = InstanceName;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;target.FileName = LogsFolder + &lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;/${shortdate}.log&amp;quot;&lt;/font&gt;&lt;/span&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;target.Layout = &lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;${date:format=HH\\:MM\\:ss} ${logger} ${message}&amp;quot;&lt;/font&gt;&lt;/span&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 10pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 10pt"&gt; config = &lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;LoggingConfiguration&lt;/font&gt;&lt;/span&gt;();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;config.AddTarget(&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;.Name, target);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 10pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 10pt"&gt; rule = &lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt; &lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;LoggingRule&lt;/font&gt;&lt;/span&gt;(&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;*&amp;quot;&lt;/font&gt;&lt;/span&gt;, &lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;LogLevel&lt;/font&gt;&lt;/span&gt;.Info, target);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;config.LoggingRules.Add(rule);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;&lt;font style="font-size: 10pt"&gt;LogManager&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 10pt"&gt;.Configuration = config;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;_logger = &lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;LogManager&lt;/font&gt;&lt;/span&gt;.GetLogger(InstanceName);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 10pt"&gt;_logger.Info(&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;Logger is initialized&amp;quot;&lt;/font&gt;&lt;/span&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;hr size="1" /&gt;&lt;/div&gt;  &lt;p&gt;This way I got all logging done on code level and as there is arbitrarily small probability that logging ever changes I am very sure that this seemingly temporary solution will live with project for long time.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9815565" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/fRO_dSeR5RA" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Windows/default.aspx">Windows</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Logging/default.aspx">Logging</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/30/how-to-make-nlog-create-separate-log-per-service-thread.aspx</feedburner:origLink></item><item><title>New ASP.NET Single Page Application Template</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/IOg7Wm_UW8k/new-asp-net-single-page-application-template.aspx</link><pubDate>Mon, 28 Jan 2013 15:20:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9812121</guid><dc:creator>DigiMortal</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9812121</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/28/new-asp-net-single-page-application-template.aspx#comments</comments><description>&lt;p&gt;I downloaded last version of &lt;a href="http://www.asp.net/vnext"&gt;ASP.NET and Web Tools 2012.2&lt;/a&gt; and digging around in Single Page Application project template. It has changed a lot compared to last beta (it was not part of stable version) and it is interesting to me to see what’s going on. I also found some good resources about SPA-s to share with your. &lt;/p&gt;  &lt;h3&gt;New default project&lt;/h3&gt;  &lt;p&gt;There is new default project for SPA-s now and it looks different than previous one. Now there is support for multiple to-do lists and of course, new design.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="ASP.NET SPA sample application" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="ASP.NET SPA sample application" src="http://weblogs.asp.net/blogs/gunnarpeipman/aspnet-spa-2012-2_6D0B610D.png" width="542" height="342" /&gt;&lt;/p&gt;  &lt;p&gt;When we take a look at project structure we will still see almost same set of files than before but there are some changes.&lt;/p&gt;  &lt;h3&gt;Upshot is gone&lt;/h3&gt;  &lt;p&gt;Big surprise to me is the fact that I cannot find upshot anymore. It was there, it provided a little bit complex but still very powerful data layer with local caching and connection detecting etc. But now it’s gone. I actually hoped to see some progress on upshot library and support for local cache based data source.&lt;/p&gt;  &lt;p&gt;Now it seems to be up to developers to handle data caching logic which is also not bad option as upshot code was at least for me a little bit hard to follow and debug. Now there is pure jQuery and Knockout and less JavaScript code than before.&lt;/p&gt;  &lt;h3&gt;Getting started&lt;/h3&gt;  &lt;p&gt;When searching some more information I found very good postings series by John Papa: &lt;a href="http://www.johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins/"&gt;Building Single Page Apps with Knockout, jQuery, and Web API – Part 1 – The Story Begins&lt;/a&gt;. Take a look at postings and examples the series provides. Although it is ten postings the postings are not too long and they are very well focused. Also I suggest reading John Papa blog post &lt;a href="http://www.johnpapa.net/insidespatemplate/"&gt;Inside the ASP.NET Single Page Apps Template Beta&lt;/a&gt; that explains how new SPA template works.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;As upshot is gone and there is enough reading now about SPA-s in ASP.NET I think I come out with some new ideas when I have gone through all the materials. It’s good to see the progress and I’m happy because SPA template is back again. Hopefully it is now simpler beast to manage than it was during upshot days.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9812121" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/IOg7Wm_UW8k" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Web+development/default.aspx">Web development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/28/new-asp-net-single-page-application-template.aspx</feedburner:origLink></item><item><title>Using Visual Studio database projects in real life</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/NLxRLsxTsm4/using-visual-studio-database-projects-in-real-life.aspx</link><pubDate>Mon, 28 Jan 2013 12:47:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9809417</guid><dc:creator>DigiMortal</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9809417</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/28/using-visual-studio-database-projects-in-real-life.aspx#comments</comments><description>&lt;p&gt;Visual Studio database projects are good to support software development. I have successfully used database projects for years and I think it’s time to share my experiences also to global developers audience. In this posting I will introduce you how to effectively use database projects so developers are working with up-to-date schema and test data all the time.&lt;/p&gt;  &lt;h3&gt;Standardizing development environments&lt;/h3&gt;  &lt;p&gt;To make things easier I will always use standardized development environments. It makes also life easier for developers because all problems that appear in environments are similar and after some time there are known solutions for all environment specific problems.&lt;/p&gt;  &lt;p&gt;One important aspect in standardization is virtualization. We (or at least those with stronger survival instinct or more experiences) use virtual machines for development because they are easy to restore and when VM is crashed then it doesn’t affect host system where usually office and other work supporting software is running. Plus you can increase or decrease the amount of resources that VM uses.&lt;/p&gt;  &lt;p&gt;For databases we usually agree in couple of things to make development easier:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;developers use local SQL Server (usually developer edition),&lt;/li&gt;    &lt;li&gt;names of databases are the same in all development machines,&lt;/li&gt;    &lt;li&gt;credentials to access databases are same in all development machines.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Yes, it is not always possible this way and there are exceptional cases but points given here work for most of projects. &lt;/p&gt;  &lt;h3&gt;Initializing database project&lt;/h3&gt;  &lt;p&gt;Some of your team who is responsible for developing database is the one who will be also manager of database project in Visual Studio solution. Writing database objects on Visual Studio, then deploying database to local machine just to test changes is non-sense. Management Studio and other WYSIWYG database management tools are way more productive and usually databases are built using these tools. I don’t want to force people to more work manually and I ‘m happy when they are moving on as fast as possible.&lt;/p&gt;  &lt;p&gt;Suppose that database guy has already started building database. There are some tables and maybe views. Maybe even some stored procedures. Let’s also suppose there is empty database project also added to solution. &lt;/p&gt;  &lt;h4&gt;1. Set target database platform&lt;/h4&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-settings_72A69808.png"&gt;&lt;img title="Set target database platform" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Set target database platform" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-settings_thumb_312BE5AF.png" width="542" height="405" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is Windows Azure SQL Database selected as target so Visual Studio will check that modifications done to schema project doesn’t conflict with SQL Azure.&lt;/p&gt;  &lt;h4&gt;2. Create schema comparison&lt;/h4&gt;  &lt;p&gt;To get changes made to database to schema project we create new database schema comparison. Schema comparison allows us to compare two different schemas. Right click on database project and select Schema Compare…&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-select-schema-compare_73BB8127.png"&gt;&lt;img title="Create schema comparison" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Create schema comparison" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-select-schema-compare_thumb_7E98626F.png" width="542" height="149" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Empty schema compare window is opened.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Empty schema compare window" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Empty schema compare window" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-empty-schema-compare_76348D18.png" width="452" height="330" /&gt;&lt;/p&gt;  &lt;p&gt;Now you have to specify source and target schema:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;source schema&lt;/strong&gt; will be your local database (you can make new connection and use Windows authentication in this case because you don’t run schema comparison under application pool or other limited account),&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;target schema&lt;/strong&gt; will be the database schema project in your solution.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here are my sample settings for source and target dialogs:&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-source-target-schema_2198AE13.png"&gt;&lt;img title="Source and target schema" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Source and target schema" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-source-target-schema_thumb_1281CF39.png" width="540" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When settings are done then click Compare button in schema compare window.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-schema-compare_45715FA0.png"&gt;&lt;img title="Schema compare window" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Schema compare window" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-schema-compare_thumb_6F052AD3.png" width="542" height="417" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can see now what objects are in database and what is action to do with object on target. If I don’t have good reason I don’t add roles and user accounts to schema project as sometimes their deployment is problematic. Take a look at object definitions window – you can see diff between source and target there.&lt;/p&gt;  &lt;h4&gt;3. Update schema project&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-updated-schema-project_7B26A4FA.png"&gt;&lt;img title="Schema project with tables" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 5px 10px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Schema project with tables" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-updated-schema-project_thumb_4C60EC58.png" width="282" height="294" /&gt;&lt;/a&gt;Now click Update button to get database objects to your schema project and save schema to file in database project folder. I usually call this file as LocalDbToSchema.scmp.&lt;/p&gt;  &lt;p&gt;Under your schema project you should see now some new folders and database objects. On sample image on right you can see some database tables that were imported from database.&lt;/p&gt;  &lt;p&gt;Now include saved database compare file to your database project. This way this comparison is always available for you and you don’t have to manually configure comparison again and again when you want to compare development database with schema project.&lt;/p&gt;  &lt;p&gt;This is the schema compare that is used mostly by database developer. Of course, after making update to schema project you have to try to build it to see that there are no errors in schema project.&lt;/p&gt;  &lt;h3&gt;Adding schema project to local database comparison&lt;/h3&gt;  &lt;p&gt;As now you have way to get schema changes from database to schema project you are ready to make another comparison that is mostly used by developers who don’t develop database. They need to compare their local databases against schema project and apply changes or recreate their databases.&lt;/p&gt;  &lt;p&gt;Steps are almost same as before:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right click on database project and select Schema Compare…&lt;/li&gt;    &lt;li&gt;For source schema select your schema project in solution&lt;/li&gt;    &lt;li&gt;For target schema select your local database&lt;/li&gt;    &lt;li&gt;Save schema as file to database project folder (SchemaToLocalDb.scmp)&lt;/li&gt;    &lt;li&gt;Include schema compare file to database project&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;This is it. As all virtual machines have same database settings then all developers can use the same schema comparison to update or recreate their schemas.&lt;/p&gt;  &lt;h3&gt;Adding test data&lt;/h3&gt;  &lt;p&gt;If you made breaking changes that cannot be deployed to existing database with data then developers need to create their databases again. Can you imagine how painful it is when new database is empty and you have to insert all data again to make even elementary things work again? The guy who manages database project will usually also manage data that is deployed to database after it is recreated.&lt;/p&gt;  &lt;h4&gt;1. Create new post-deployment script&lt;/h4&gt;  &lt;p&gt;Right click on database project, select Add…, select New Item… and select Post-Deployment Script.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-add-post-deployment-script_38D38CB7.png"&gt;&lt;img title="Create new post-deployment script" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Create new post-deployment script" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-add-post-deployment-script_thumb_62D38ADF.png" width="540" height="304" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Name it as Script.PostDeployment.sql by example. I’m using often only one script and that’s usually enough for me. Click Add and new post-deployment script will be added to database project. Here you can see the empty window of post-deployment script:&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-empty-deployment-script_4173E543.png"&gt;&lt;img title="Empty window of post-deployment script" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Empty window of post-deployment script" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-empty-deployment-script_thumb_5C400B4F.png" width="542" height="389" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To this script you must add all test data and keep it up to date so developers have only minimum delays in work when something happens to database. Yes, it is additional work to keep data up to date but as database developer you should know very well how to produce test data and how to get data from database to clipboard. &lt;/p&gt;  &lt;h3&gt;Publish profile&lt;/h3&gt;  &lt;p&gt;You need two database publish profiles. Schema comparison doesn’t work for you when developer has to delete database and create it again. Yes, schemas are compared but data doesn’t appear to new database automatically. Of course, it is possible to take data with copy and paste from post-deployment script but why so much manual work when we have tools that work nice for us?&lt;/p&gt;  &lt;p&gt;Right click on database project, select Publish… You are asked for target database connection string. Add connection to your local development database and then click on button Advanced…&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-advanced-publish-settings_459DBD08.png"&gt;&lt;img title="Advanced publishing settings" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="Advanced publishing settings" src="http://weblogs.asp.net/blogs/gunnarpeipman/vs2012-database-advanced-publish-settings_thumb_724676E1.png" width="535" height="656" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Set publishing options like I have (should work for most projects you have) and then click OK.&lt;/p&gt;  &lt;p&gt;Now save publishing settings to file called PublishToLocal.publish.xml and make sure this file is included to database project. When some developer explodes database then it is easy to recreate it again now. &lt;/p&gt;  &lt;h3&gt;Updating test and production databases&lt;/h3&gt;  &lt;p&gt;You have also test databases that are used in test environments where users and testers test the system. Also you have production databases. It would be nice if all changes get there automatically but life has shown that for these systems you have to deal mostly manually. You must be sure that you don’t break something and you don’t delete any important data by mistake. &lt;/p&gt;  &lt;p&gt;You can still use database comparisons to compare current schema to test or production database but I recommend you to &lt;strong&gt;use database accounts that have no permissions to modify data or database objects&lt;/strong&gt;. Schema comparisons will show you what changes are needed for target databases but you have to do these changes manually and not trust automatics. Even if you have publishing options set correctly you cannot always be sure that automatic modifications are done the way you expected. Make on mistake and face worst problems you have ever seen.&lt;/p&gt;  &lt;p&gt;Until you just compare two schemas to find out differences and you use “read-only” accounts you are in safer waters.&lt;/p&gt;  &lt;h3&gt;How it works in practice&lt;/h3&gt;  &lt;p&gt;So far, so good. My teams have saved remarkable amount of time to fix mysterious database issues and setting up databases again. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;All developers know how to use database projects regardless their actual role in projects.&lt;/li&gt;    &lt;li&gt;Database and environment related issues are usually easy to find because development environments are standardized and unknown issues appear only when doing something “unusual”.&lt;/li&gt;    &lt;li&gt;Crashed or screwed up database gets back to life with about 15 minutes at maximum.&lt;/li&gt;    &lt;li&gt;Mismatches between database and code are quickly detected and fixed.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You need well disciplined developers to use things like this because guys who don’t really care about quality will just screw up all thing by out-dating schema project and post-deployment scripts. For good developers database projects save time and help them keep work quality high.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;Database projects in Visual Studio are powerful tools to use. This posting gave you overview about how to use database projects when developing systems where databases with regular size and structure are used. For more complex and advanced scenarios also rules change and different problems like big amounts of data or impossibility to use local databases may need workarounds. Until it’s regular development you can easily use database projects like described here. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9809417" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/NLxRLsxTsm4" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Databases/default.aspx">Databases</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Tools/default.aspx">Tools</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/28/using-visual-studio-database-projects-in-real-life.aspx</feedburner:origLink></item><item><title>My experiences with Knockout</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/IXumXynH1fM/my-experiences-with-knockout.aspx</link><pubDate>Sun, 27 Jan 2013 22:29:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9807325</guid><dc:creator>DigiMortal</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9807325</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/27/my-experiences-with-knockout.aspx#comments</comments><description>&lt;p&gt;It has been quite here for some month as I was very busy on some critical projects and I also got used to be a father to one wonderful baby. Now it’s time to get back to community stuff and this time I will dig to fancy JavaScript library called &lt;a href="http://knockoutjs.com/"&gt;Knockout&lt;/a&gt;. This was one of interesting journeys I have had together with fellow &lt;a href="http://weblogs.asp.net/hajan/"&gt;ASP.NET MVP Hajan Selmani&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;How I got to Knockout&lt;/h3&gt;  &lt;p&gt;Knockout was decision that was to be made in one project where UI is making heavy use of AJAX. Although there were other ways how to go we got some technical decisions that were not adequate and that left not much room for us. &lt;/p&gt;  &lt;p&gt;As we had business logic implemented in database level we built WCF service so UI can communicate with database and we can also solve some issues in server side code so we don’t affect UI with every change we make.&lt;/p&gt;  &lt;p align="center"&gt;&lt;img title="Layers in our system" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Layers in our system" src="http://weblogs.asp.net/blogs/gunnarpeipman/ui-wcf-db_658382E3.png" width="324" height="124" /&gt;&lt;/p&gt;  &lt;p&gt;This is how the communication between layers was organized in big picture. We had to find something to make communication between UI and server as painless as the choice was knockout. Actually Hajan suggested it at first place and it take me a little time to get to this idea but now I like the idea, of course.&lt;/p&gt;  &lt;h3&gt;What is Knockout?&lt;/h3&gt;  &lt;p&gt;Knockout is JavaScript library that allows to implement declarative model binding and use observable variables and collections. This is like client side implementation of MVVM but the engine that it is running on is JavaScript. I hope this explanation is simple enough to get the idea.&lt;/p&gt;  &lt;p&gt;Coding with Knockout is as follows:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;write code to get data from server, &lt;/li&gt;    &lt;li&gt;write templates for repeated data, &lt;/li&gt;    &lt;li&gt;add data binding attributes to HTML elements, &lt;/li&gt;    &lt;li&gt;bind data to page. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is fragment on page that uses Knockout to show data. data-bind attribute is the one that Knockout checks. In this attribute you tell to Knockout all it has to do with element. On this example you can see foreach, click, text and clickBubble attributes.&lt;/p&gt;  &lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 9.8pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;foreach: $root.Products()&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;ui-state-default&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;        &lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;click: function(data){$root.SetCurrentProduct(data)&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text: ProductName&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;          &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;moveUp&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;click: function(data){MoveProductUp(data)},          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; clickBubble: false&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;moveDown&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;click: function(data){MoveProductDown(data)},          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; clickBubble: false&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;       &lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 9.8pt" color="#0000ff"&gt;&amp;gt;        &lt;hr size="1" /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;  &lt;p&gt;Syntax of attributes may feel weird at first but still it’s better to have one HTML-attribute to avoid possible clashes with other libraries. &lt;/p&gt;  &lt;h3&gt;Getting data from server&lt;/h3&gt;  &lt;p&gt;If you are building rich user interface you probably have enough calls for data to server that you need some service classes. &lt;/p&gt;  &lt;hr size="1" /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; ProductService() {        &lt;br /&gt;        &lt;br /&gt;}         &lt;br /&gt;        &lt;br /&gt;ProductService.prototype.GetProductsForUser = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (categoryId, callback) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.ajax({         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;POST&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contentType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;application/json; charset=utf-8&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;json&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;ProductService.svc/GetProductsForUser&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data: { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;categoryId&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;: categoryId },        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; success: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (response) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; callback === &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;function&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;) callback(response);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; },         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; error: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt; () {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; callback === &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;function&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;) callback(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;error&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });         &lt;br /&gt;};         &lt;hr size="1" /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;Classes like these help us divide service calls to special service classes on UI side so our code remains organized and clean.&lt;/p&gt;  &lt;h3&gt;View models&lt;/h3&gt;  &lt;p&gt;As a next thing we need view models for our pages. View models provide data and operations to HTML page and bindings are controlled by Knockout. If we are using collections that users may change through UI code then we can use observable collections that reflect changes through bindings automatically back to HTML DOM. &lt;/p&gt;  &lt;p&gt;Using of view models like this is optional – you can organize your code the way you like. As we had some view specific logics we started using view models so we have view model for each HTML page and we can go on with object-oriented code that we love usually most.&lt;/p&gt;  &lt;hr size="1" /&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt; ProductViewModel() {         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.Products = ko.observableArray();&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;     &lt;br /&gt;}    &lt;br /&gt;&amp;#160; &lt;br /&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 9.8pt"&gt;ProductViewModel.prototype.Initialize = &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ko.applyBindings(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;, $(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;'#ProductForm'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;)[0]);&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;        &lt;br /&gt;}         &lt;br /&gt;&amp;#160; &lt;br /&gt;ProductViewModel.prototype.LoadProducts = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Products.splice(0, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Products().length);        &lt;br /&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; productService.LoadProducts(null, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (data) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (data == &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;'error'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; console.error(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;'error loading products'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; i = 0; i &amp;lt; data.LoadProductsResult.length; i++) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; product = data.LoadProductsResult[i];        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; product.Categories = ko.observable(product.Categories);         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; productModel.Products.push(product);         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 9.8pt"&gt;&lt;font color="#000000"&gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });         &lt;br /&gt;}         &lt;hr size="1" /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;When view model is initialized then Knockout is binding view model to products form element. After that products are loaded from server and products collection is filled with products. As products collection is array observed by Knockout then products list on screen is filled automatically. We can use templates for single products and keep this way our forms simpler to read.&lt;/p&gt;  &lt;h3&gt;What were main wins using Knockout?&lt;/h3&gt;  &lt;p&gt;As I am not big JavaScript guru and we had most forms not very simple then my biggest wins are these:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;no need for long-long code to control the UI,&lt;/li&gt;    &lt;li&gt;no need for long code to bind data to form elements,&lt;/li&gt;    &lt;li&gt;HTML got way cleaner and shorter when using Knockout,&lt;/li&gt;    &lt;li&gt;Knockout worked also in more complex situations where more than one view model per page was needed.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Practically Knockout solved almost all nightmares I was afraid of to happen. &lt;/p&gt;  &lt;h3&gt;How to get started?&lt;/h3&gt;  &lt;p&gt;I got started using Knockout home page. They have pretty good tutorial and also good examples:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://learn.knockoutjs.com/"&gt;Knockout tutorials&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://knockoutjs.com/examples/"&gt;Knockout live examples&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I started from these pages and got on my feet with Knockout quickly.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;Knockout is easy to learn although it takes some time to find out all powerful features it has and find answers to questions when working with more complex scenarios. Although materials at Knockout site are very good they don’t explain all things but using search engines I was able to solve all problems I faced. I also had some problems when Knockout got confused but mostly these were simple issues. After week or two with Knockout I found it to be extremely valuable library to use even in more complex scenarios.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9807325" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/IXumXynH1fM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Web+development/default.aspx">Web development</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/JavaScript/default.aspx">JavaScript</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2013/01/27/my-experiences-with-knockout.aspx</feedburner:origLink></item><item><title>Travelling MVP #4: DevReach 2012</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/qj5tOgE_Ib0/travelling-mvp-4-devreach-2012.aspx</link><pubDate>Sat, 27 Oct 2012 10:25:35 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9228063</guid><dc:creator>DigiMortal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9228063</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/27/travelling-mvp-4-devreach-2012.aspx#comments</comments><description>&lt;p&gt;Our next stop after Varna was Sofia where DevReach happens. DevReach is one of my favorite conferences in Europe because of sensible prices and strong speakers line-up. Also they have VIP-party after conference and this is good event to meet people you don’t see every day, have some discussion with speakers and find new friends.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a title="DevReach" href="http://www.devreach.com/" rel="DevReach"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="devreach-2012-large" border="0" alt="devreach-2012-large" src="http://weblogs.asp.net/blogs/gunnarpeipman/devreach-2012-large_131967A1.png" width="542" height="178" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Our trip from Varna to Sofia took about 6.5 hours on bus. As I was tired from last evening it wasn’t problem for me as I slept half the trip. After smoking pause in Velike Tarnovo I watched movies from bus TV. We had supper later in city center Happy’s – place with good meat dishes and nice service. And next day it begun…. :)&lt;/p&gt;  &lt;h3&gt;DevReach 2012&lt;/h3&gt;  &lt;p&gt;DevReach is held usually in Arena Mladost. It’s near airport and Telerik office. The event is organized by local MVP &lt;a href="http://www.kulov.net/"&gt;Martin Kulov&lt;/a&gt; together with Telerik. Two days of sessions with strong speakers is good reason enough for me to go to visit some event. Some topics covered by sessions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Windows 8 development&lt;/li&gt;    &lt;li&gt;web development&lt;/li&gt;    &lt;li&gt;SharePoint&lt;/li&gt;    &lt;li&gt;Windows Azure&lt;/li&gt;    &lt;li&gt;Windows Phone&lt;/li&gt;    &lt;li&gt;architecture&lt;/li&gt;    &lt;li&gt;Visual Studio&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/178490_3872705302817_715153932_o_50C64F5D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="178490_3872705302817_715153932_o" border="0" alt="178490_3872705302817_715153932_o" align="right" src="http://weblogs.asp.net/blogs/gunnarpeipman/178490_3872705302817_715153932_o_thumb_2702D46A.jpg" width="226" height="242" /&gt;&lt;/a&gt;Practically everybody can find some interesting session in every time slot. As the Arena is not huge it is very easy to go from one sessions to another if selected session for time slot is not what you expected.&lt;/p&gt;  &lt;p&gt;On the second floor of Arena there are many places where you can eat. There are simple chunk-food places like Burger King and also some restaurants. If you are hungry you will find something for your taste for sure. Also you can buy beer if it is too hot outside :)&lt;/p&gt;  &lt;p&gt;Weather was very good for October – practically Estonian summer – 25C and over.&lt;/p&gt;  &lt;h3&gt;Sessions I visited&lt;/h3&gt;  &lt;p&gt;Here is the list of sessions I visited at DevReach 2012:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;DevReach 2012 Opening &amp;amp; Welcome Messsage with Martin Kulov and Stephen Forte&lt;/li&gt;    &lt;li&gt;Principled N-Tier Solution Design with Steve Smith&lt;/li&gt;    &lt;li&gt;Data Patterns for the Cloud with Brian Randell&lt;/li&gt;    &lt;li&gt;.NET Garbage Collection Performance Tips with Sasha Goldshtein&lt;/li&gt;    &lt;li&gt;Building Secured, Scalable, Low-latency Web Applications with the Windows Azure Platform with Ido Flatow&lt;/li&gt;    &lt;li&gt;It’s a Knockout! MVVM Style Web Applications with Charles Nurse&lt;/li&gt;    &lt;li&gt;Web Application Architecture – Lessons Learned from Adobe Brackets with Brian Rinaldi&lt;/li&gt;    &lt;li&gt;Demystifying Visual Studio 2012 Performance Tools with Martin Kulov&lt;/li&gt;    &lt;li&gt;SPvNext – A Look At All the Exciting And New Features In SharePoint with Sahil Malik&lt;/li&gt;    &lt;li&gt;Portable Libraries – Why You Should Care with Lino Tadros&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I missed some sessions because of some death march projects that are going and that I have to coordinate but it was not big loss as I had time to walk around in session venue neighborhood and see Sofia Business Park.&lt;/p&gt;  &lt;h3&gt;Next year again!&lt;/h3&gt;  &lt;p&gt;I will be there again next year and hopefully more guys from Estonia will join me. I think it’s good idea to take short vacation for DevReach time and do things like we did this time – Bucharest, Varna, Sofia. It’s only good idea to plan some more free time so we are not very much in hurry and also we have no work stuff to do on the trip. This far this trip has been one of best trips I have organized and I will go and meet all those guys in this region again! :)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9228063" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/qj5tOgE_Ib0" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Community+news/default.aspx">Community news</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Travelling+MVP/default.aspx">Travelling MVP</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/27/travelling-mvp-4-devreach-2012.aspx</feedburner:origLink></item><item><title>Travelling MVP #3: Community event in Varna, Bulgaria</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/jsSW40VsAAs/travelling-mvp-3-community-event-in-varna-bulgaria.aspx</link><pubDate>Sat, 27 Oct 2012 00:03:54 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9223170</guid><dc:creator>DigiMortal</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9223170</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/27/travelling-mvp-3-community-event-in-varna-bulgaria.aspx#comments</comments><description>&lt;p&gt;Second stop in my DevReach 2012 trip was at Varna. We had not much time to hang around there but this problem will get fixed next year if not before. But still we had sessions there with Dimitar Georgijev and I had also chance to meet local techies. Next time we will have more tech and beers for sure!&lt;/p&gt;  &lt;p&gt;We started in the morning from Bucharest and travelled through Ruse, Razgrad and Shumen to Varna. It’s about 275km. We used cab, local bus and Dimitar father’s car. We had one food stop in Ruse and after that we went directly to Varna. Here is our route on map. &lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/2012-bucharest-varna_32D657CC.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="2012-bucharest-varna" border="0" alt="2012-bucharest-varna" src="http://weblogs.asp.net/blogs/gunnarpeipman/2012-bucharest-varna_thumb_2C7F5B71.png" width="542" height="437" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Varna is Bulgarian city that locates on western coast of Black Sea. I have been there once before this trip and it’s good place to have vacation under sun. Also autumn is there milder than here in Estonia (third day of snow is going on). Bulgaria has some good beers, my favorite mankind killer called rakia and very good national cuisine. Food is made of fresh stuff and it is damn good experience. Here are some arbitrarily selected images (you can click on these to view at original size):&lt;/p&gt;  &lt;table border="0" cellspacing="2" cellpadding="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/557751_4110071463669_1149193415_n_4E3B0E35.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="557751_4110071463669_1149193415_n" border="0" alt="557751_4110071463669_1149193415_n" src="http://weblogs.asp.net/blogs/gunnarpeipman/557751_4110071463669_1149193415_n_thumb_4B45A982.jpg" width="182" height="137" /&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/523164_4115203631970_1365621628_n_57D3569E.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="523164_4115203631970_1365621628_n" border="0" alt="523164_4115203631970_1365621628_n" src="http://weblogs.asp.net/blogs/gunnarpeipman/523164_4115203631970_1365621628_n_thumb_40C4D562.jpg" width="182" height="137" /&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td&gt;&lt;a href="http://weblogs.asp.net/blogs/gunnarpeipman/548617_4115067828575_389598513_n_6D6D8F3B.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="548617_4115067828575_389598513_n" border="0" alt="548617_4115067828575_389598513_n" src="http://weblogs.asp.net/blogs/gunnarpeipman/548617_4115067828575_389598513_n_thumb_36B03437.jpg" width="182" height="137" /&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td align="center"&gt;Old bus “monument”          &lt;br /&gt;in Razgrad&lt;/td&gt;        &lt;td align="center"&gt;Stuffed peppers, Bulgarian         &lt;br /&gt;national cuisine&lt;/td&gt;        &lt;td align="center"&gt;Infra-red community having good time and beers&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;We made our sessions at one study class of Varna technical university. It’s a little bit old style university but everything we needed was there and we had no problems with machinery. Sessions were same as in Bucharest.&lt;/p&gt;  &lt;p&gt;The user group in Varna is brand new and hopefully it will be something bigger one good day. At least I try to make my commits so they get on their feet quicker. As we had not much time to announce the event there was about 15 guys listening to us and I’m happy that it was not too much hyped event because still I was getting my first experiences with foreign audiences. After sessions we took our stuff to hotel and went to hang around with local techies. We had some good time there and made some new friends.&lt;/p&gt;  &lt;p&gt;Next time when I go to Varna I go back as more experienced speaker and I plan to do there one tougher and highly challenging session. Maybe somebody from Estonian community will join me and then it will be well planned surprise-attack to Varna :)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9223170" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/jsSW40VsAAs" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Community+news/default.aspx">Community news</category><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Travelling+MVP/default.aspx">Travelling MVP</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/27/travelling-mvp-3-community-event-in-varna-bulgaria.aspx</feedburner:origLink></item><item><title>Windows Azure development storage and StorageServerException (Error 500)</title><link>http://feedproxy.google.com/~r/gunnarpeipman/~3/9rwHI3JXr-Q/windows-azure-development-storage-and-storageserverexception-error-500.aspx</link><pubDate>Sat, 20 Oct 2012 17:01:27 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9159196</guid><dc:creator>DigiMortal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/gunnarpeipman/rsscomments.aspx?PostID=9159196</wfw:commentRss><comments>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/20/windows-azure-development-storage-and-storageserverexception-error-500.aspx#comments</comments><description>&lt;p&gt;When preparing my Sinergija12 code examples I ran into interesting problem. Windows Azure local development storage hangs for about minute and gives StorageServerException stating that there was problem in web server. A little surf in search engines gave me solution.&lt;/p&gt;  &lt;p&gt;For me this error happened with default settings of development storage. Everything started working normally when I created storage database to my local SQL Server. MSDN library has good article about steps to take: &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg433134.aspx"&gt;How to Configure SQL Server for the Storage Emulator&lt;/a&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Click Start, point to All Programs, and then click Windows Azure SDK.&lt;/li&gt;    &lt;li&gt;Right-click Windows Azure SDK Command Prompt, and then click Run as administrator.&lt;/li&gt;    &lt;li&gt;In the Windows Azure SDK Command Prompt window, type the following command:     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DSInit /sqlInstance:&amp;lt;SQLServerInstance&amp;gt;      &lt;br /&gt;Where &amp;lt;SQLServerInstance&amp;gt; is the name of the SQL Server instance.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Before running these commands shut down Storage Emulator. You can run it when you are done on Azure command-line.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9159196" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/gunnarpeipman/~4/9rwHI3JXr-Q" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/gunnarpeipman/archive/tags/Azure/default.aspx">Azure</category><feedburner:origLink>http://weblogs.asp.net/gunnarpeipman/archive/2012/10/20/windows-azure-development-storage-and-storageserverexception-error-500.aspx</feedburner:origLink></item></channel></rss>
