2
votes

From this https://stackoverflow.com/a/18404091/24267 I gather that

The customErrors attribute is used when the .net code is throwing an exception (404, 403, 500 etc) and the httpErrors attribute is used when IIS itself is throwing an exception.

I want QA to be able to test my 500 page. It's easy enough to throw an asp.net exception to test customErrors ("throw new Exception()" in an .aspx page), but how do I force IIS to throw an exception to test httpErrors?

1
add a page to your site, and add Response.StatusCode to the error value you want in that page initialization and let CustomErrors handle that errortechspider

1 Answers

3
votes

I had the same requirement and appreciated @techspider's suggestion. Building on that I thought I'd post the minimal ASPX file I used to trigger the error, to save someone else refreshing themselves on ASPX syntax like I just did.

<%@ Page Language="C#" %>

<%
  Response.StatusCode = 500;
%>