我已成功添加自定义404页面.我想要做的是创建另一个自定义错误页面,当有404以外的任何错误时显示该错误页面. 500,403等
这就是我现在在webconfig中所拥有的
<httpErrors errorMode="Custom" existingResponse="Replace"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" path="/404.aspx" responseMode="ExecuteURL"/> </httpErrors>
解决方法
天啊.我不敢相信我找不到这个简单问题的正确答案!然而,经过2个小时的阅读文档和调试,我找到了它.
<httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" defaultPath="/App/Error"> <!-- Do not include ~,this was my issue all long --> <clear/> <!-- so that IIS provided error pages are skipped --> <!-- add those which you like to provide a view of yours --> <error path="/App/Http404" responseMode="ExecuteURL" statusCode="404"/> <error path="/App/Http503" responseMode="ExecuteURL" statusCode="503"/> </httpErrors>
要知道< httpErrors>配置IIS,而< customErrors>配置ASP.NET和一些旧版本的IIS(< = 6?).