Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Added null check for CurrentHttpContext #77

merged 1 commit into from

2 participants


This was a small thing that bit me when I first tried to use MvcMailer. I had not passed in an HttpContext and it exploded (as it should), but it gave me a object reference error. I just added a check for to throw a specific exception message if it's null instead of throwing a generic object reference exception

@smsohan smsohan merged commit 7cd782b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 28, 2012
  1. @mmooney
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 Mvc.Mailer/MailerBase.cs
5 Mvc.Mailer/MailerBase.cs
@@ -245,7 +245,10 @@ public class MailerBase : ControllerBase {
private void CreateControllerContext() {
- var routeData = RouteTable.Routes.GetRouteData(CurrentHttpContext);
+ if (CurrentHttpContext == null) {
+ throw new ArgumentNullException("CurrentHttpContext", "CurrentHttpContext cannot be null");
+ }
+ var routeData = RouteTable.Routes.GetRouteData(CurrentHttpContext);
ControllerContext = new ControllerContext(CurrentHttpContext, routeData, this);
Something went wrong with that request. Please try again.