26th April 2014

MVC3: Layouts, RenderBody, RenderPage, RenderSection

MVC3: Layouts, RenderBody, RenderPage, RenderSection Layouts You typically want to maintain a consistent look and feel across all of the pages within your web-site/application.ASP.NET 2.0 introduced the concept of “master pages” which helps enable this when using .aspx based pages or templates. Razor supports this concept with a feature called “layouts”- which allow us to define a common site template, and then inherit its look and feel across all the views/pages on our site. RenderBody The RenderBody method resides in the layout page. There can only be one RenderBody method per layout page. The RenderBody method indicates where view templates […]
9th April 2014

How Linq to Objects Queries Work

If you have ever tried to step through a Linq to Objects query in the debugger, you may have been mildly surprised at the results. It may have seemed as if the program had a mind of its own and ran certain expressions when it wanted to and not when it was supposed to. Be assured, it is doing the right thing and the order of evaluation is giving you a glimpse of what actually happens when a query is evaluated. Consider this query: using System; using System.Linq; class Program { static void Main() { var foo = new[] { […]