我在.ascx中有一些代码如下所示:
<%
int a = 0;
int b = 5;
int c = b/a;
%>如预期的那样抛出一个500错误(除以0)。
CustomErrors看起来像这样
<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="500" redirect="/500.aspx" />
</customErrors>我想要点击的那一页呈现得很糟糕。查看源代码,我看到一半的普通页面,然后500页跟随它。
<div class="mapTextOverlay" style="width:448px;padding-left:232.96px;">
[main page abruptly ends here and the 500 page starts]
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head"><title>
500
</title>
[etc.]因此,服务器传输发生在页面呈现的中间。
如何在500错误的情况下防止部分页面呈现的可能性?
发布于 2017-06-06 18:03:30
我仍然不知道为什么会发生这种情况,但解决办法却很简单。
将Response.Clear();放在500页的Page_Load()中。
https://stackoverflow.com/questions/43147407
复制相似问题