如何强制IIS引发异常 [英] How to force IIS to throw an exception

查看:58
本文介绍了如何强制IIS引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从此 https://stackoverflow.com/a/18404091/24267 我收集到

当.net代码抛出异常时,将使用customErrors属性. 异常(404、403、500等),并使用了httpErrors属性 当IIS本身引发异常时.

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.

我希望质量检查人员能够测试我的500页.抛出asp.net异常以测试customErrors很容易(在.aspx页面中抛出new Exception()"),但是如何强制IIS抛出异常以测试httpErrors?

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?

推荐答案

我有相同的要求,并赞赏@techspider的建议.在此基础上,我认为我会发布用来触发错误的最小ASPX文件,以节省其他人像我刚才那样使用ASPX语法刷新自己的内容.

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;
%>

这篇关于如何强制IIS引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆