Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created August 5, 2009 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/162758 to your computer and use it in GitHub Desktop.
Save stevenharman/162758 to your computer and use it in GitHub Desktop.
/// <summary>
/// Bypasses IIS7 custom Errors.
/// </summary>
public class TrySkipIisCustomErrors : FilterAttribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
}
public void OnActionExecuted(ActionExecutedContext filterContext) { }
}
public class when_communicating_raw_errors_to_a_client : concerns<TrySkipIisCustomErrors>
{
private ActionExecutingContext _filterContext;
private HttpResponseBase _response;
protected override void context()
{
var handler = new TrySkipIisCustomErrors();
var httpContext = fake<HttpContextBase>();
_response = stub<HttpResponseBase>();
httpContext
.Stub(c => c.Response)
.Return(_response);
_filterContext = new ActionExecutingContext {HttpContext = httpContext};
handler.OnActionExecuting(_filterContext);
}
[Specification]
public void skip_iis7_custom_errors()
{
_response.TrySkipIisCustomErrors.should_be_true();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment