Recently I was working on reducing some redundancy in an ASP.NET MVC application and ran into an error when trying to conditionally render a section. ASP.NET was not happy and gave me the following error:

The following sections have been defined but have not yet been rendered for the layout page “~/Views/Shared/_Layout.cshtml”: “ProductionOnlyScripts”.

On this layout page we have the following code.

@if (ApplicationConfiguration.IsProduction)
    @RenderSection("ProductionOnlyScripts", false)

I never expected that if I defined a section that MVC would require me to render it. I can kind of understand why, but I disagree with this design decision. Lets run down the options we have with sections in general.

  1. Calling @RenderSection(name) when the section has not been defined will throw an error. This is the right thing to do.
  2. Calling @RenderSection(name, required: false) when the section has not been defined will not throw an error. This is the right thing to do.
  3. Not calling @RenderSection(name) or @RenderSection(name, required: false) will throw an error if that section has been defined (as is what we have observed).

So, the work around to this is simple: we render the section to nothing.

@if (ApplicationConfiguration.IsProduction)
    @RenderSection("ProductionOnlyScripts", false)
    RenderSection("ProductionOnlyScripts", false)?.WriteTo(TextWriter.Null);

In the end, ASP.NET is tracking the section fragment and ensuring that we are writing out it’s contents. What it doesn’t know is that we are just writing that to /dev/null effectively so that the content will never make it’s way to the browser.

This can be extended as well into an extension method if you find yourself doing this often.

The only real mistake is the one from which we learn nothing.

John Powell

Let’s make one thing clear: being a candidate in an interview is hard. Over your career you will likely participate in many interviews as a candidate, and I can assure you that you likely won’t pass every single one. You aren’t alone here, I myself am no stranger to failed interviews. You can, however, make sure that you are getting something out of every single interview: a new job, exposure to a new problem, a new way to solve a problem, or a better understanding of a problem.

As I have been interviewing candidates recently for a software engineer position at DevResults, I’ve been thinking about what I would do if I had been the candidate in these interviews and I’ve compiled my current thoughts into a few general tips. Some of these are technical interview specific, but the majority are generally applicable to all interviews in general.

Failing a problem is an opportunity to learn

One interview I participated in I was asked to return all permutations of a string. At the time, I had never had to do something like this, and needless to say I didn’t do well on it. After the interview I took the time to really understand the problem and strategies for generating permutations in general, mainly to ensure I wouldn’t ever fail that question again.

Fast-foward to last year, I found myself in a scenario where I did in fact need to generate all possible permutations for a set of data. It made me really appreciate that I had been exposed to that problem in the past from the interview and it was pretty trivial to apply what I had learned to solve the problem.

Most of the time, however, you’ll probably see something you’ve encountered before, or some variation of a known problem. In scenarios like these, there’s often multiple ways to approach a problem and if you didn’t quite get it, the interviewer may explain the solution to you or you can ask what the solution is. If you are able to get the solution to the problem, definitely take the time later to make sure you understand the solution and why it’s the right solution.

If you actually got the solution, but in a non-optimal way (perhaps your solution had poor runtime performance or poor memory usage), be sure to note the problems your algorithm had and research solutions that address those issues.

Ask for feedback

Don’t hesitate to ask for feedback or suggestions on how you did in an interview, but keep your question focussed on your performance. A lot of the time, you won’t get a response for various reasons like company policy prevents the interviewer from giving any feedback to you. Any feedback you are able to get, however, can be very important.

Every interview I conduct I block off an hour and a half which is broken into three parts:

  • The first 10 - 15 minutes I go over the job description and get to know a little more about the candidate
  • The next 45 minutes is dedicated to the candidate answering technical questions
  • The remaining 30 minutes is open question time for the candidate

The vast majority of the time candidates spend about 10 - 15 minutes asking the usual questions like what kind of source control we use, how we do deployments, etc. The other day, howerver, one candidate took full advantage of this time, which I always explicitly say is open Q&A. The candidate asked for feedback on their resume, how well they were communicating while they were coding, how well I could understand them (they were a non-native english speaker), and many other questions.

The insight was extremely valuable for them personally and likely not something any company policy would bar. Before and after each interview, think critically about what things you struggle with and try to get feedback from the interviewer on how they think you did in those regards. This will help you do better in all subsequent interviews.

The only way to get better at interviewing is to do interviews

This seems like common sense advice, but it really is true. If you are having a hard time with interviews, you just need to do more of them. Generally, people only apply to companies or jobs that they are really interested in and waiting to apply to other positions that they would likely be happy with but definitely not their first choice. This is fine, but it can be really demotivating when you don’t make the cut for positions you are really interested in.

When I’m job searching, I tend to take a balanced approach and apply to both types of positions, which allows me to practice interviewing and reduce risk of failing an interview with someplace I really want to work at just because my nerves got to me. It would be unethical to waste someones time by applying to positions you wouldn’t ever want though, so only apply to jobs you can see yourself being happy in.

The last time I went through the hiring process it actually became a little complicated in the end because I ended up facing a situation where I would have to choose between a job I thought I would really like and a position that when I had originally applied I thought I could be happy with but I knew I really wanted after I had met the people involved and learned more about the mission / vision.

Out of the box, posh-git uses a red color that's a bit hard to read against most background colors. All hope is not lost, because it's very easy to fix.

The console on windows has some named colors built-in and posh-git is configured to use DarkRed. While we can’t change the named color that PoshGit uses, we can change the color that the console displays. To do this, simply right-click on the powershell icon, then select properties from the drop down menu.

It should be pretty clear which color in the row of colors is dark red, but if it isn’t then it is the fifth color from the left.

Once you select the dark red color, you can the selected color values to a more humane color. As can be seen in the screenshot, I’ve chosen a salmon color (R: 255, G: 154, B: 154) which goes well with my black color. Now, likely you’re still on Screen Background and the console background has changed to a salmon color, so just remember to re-select the previous background color before you hit Ok.

That’s it. Now hopefully you’ll have a more humane posh-git experience.

I just released two new nuget packages: libsassnet and libsassnet.Web.

A while ago I blogged about the state of Sass support in ASP.NET. Since then, a lot has changed: Sass hit version 3.3, libsass has become extremely popular, and Visual Studio 2013 now has support for Sass built in.

Unfortunately in the case of NSass, it hasn’t been updated in over a year. For that reason, I’ve been porting most of the functionality over to libsass-net, and the nuget packages and ASP.NET integration has been a glaring whole in that project for a while.


Since libsass is a C++ project, you’ll need to make sure you have the Visual C++ Redistributable installed. I’m not a C++ expert, so I’m not sure if the latest version works or if you need the 2012 version.

Integrating with System.Web.Optimization

Integrating with the System.Web.Optimization project is very simple with libsass. Below is an example configuration:

var sass = new SassBundle("~/content/css", basePath: "~/sass")


We just started using NewRelic at work and I’ve really been digging it. We also use SignalR which (by design) can use long-polling connections. Unfortunately, those tend connections to skew the metrics in NewRelic. Fortunately, NewRelic provides an API to ignore certain transactions, so I thought I’d be able to tell it to just ignore signalr.

At first, I tried this answer on StackOverflow, but it ended up ignoring all requests, not just the ones for SignalR. In the end I had to use an Owin module to get the job done.

Here is the code I ended up with

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using AppFunc = Func<IDictionary<string,object>, Task>;

public class NewRelicIgnoreTransactionOwinModule
	private AppFunc _nextAppFunc;
	public NewRelicIgnoreTransactionOwinModule(AppFunc nextAppFunc)
		_nextAppFunc = nextAppFunc;

	public Task Invoke(IDictionary<string, object> environment)
		object request = null;
		if (environment.TryGetValue("owin.RequestPath", out request)) {
			if (((string)request).IndexOf("signalr", StringComparison.OrdinalIgnoreCase) > -1) {

		return _nextAppFunc(environment);

To use this in your owin startup code call the following