gpt4 book ai didi

security - MVC - CustomErrors 在设置 redirectMode =“ResponseRewrite” 时不起作用

转载 作者:行者123 更新时间:2023-12-04 06:45:52 26 4
gpt4 key购买 nike

我有一个在 IIS 6.0 上运行的 ASP.NET 4.0 MVC Web 应用程序,其 webconfig 自定义错误部分为:

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/Home/Error">
<error statusCode="403" redirect="/Home/Error"/>
<error statusCode="404" redirect="/Home/Error"/>
</customErrors>

和一个如下所示的 error.aspx 页面:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Mvc.HandleErrorInfo>" %>

<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Error
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Error Processing your request.</h2>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Scripts" runat="server">
<script runat="server">
void Page_Load() {
byte[] delay = new byte[1];
RandomNumberGenerator prng = new RNGCryptoServiceProvider();

prng.GetBytes(delay);
Thread.Sleep((int)delay[0]);

IDisposable disposable = prng as IDisposable;
if (disposable != null) { disposable.Dispose(); }
}
</script>
</asp:Content>

每当我在 webconfig 自定义错误部分包含上述“redirectMode="ResponseRewrite"” 时,重定向到我的自定义错误页面不再有效,并且我收到“/”应用程序中的服务器错误 - 找不到资源”的页面错误。事实上, Controller Action 也被忽略了。当我采取这种设置时,我们的一切都按原样进行。我正在尝试将 Scott Gu 的解决方法用于此处列出的 Asp.net 安全漏洞: http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx

任何帮助将不胜感激。
谢谢,
比利

最佳答案

不幸的是,您不能拥有任何 <error> <customErrors> 中的标签根据 Scott Guthrie 的说法,阻止。他们肯定正在开发补丁,但与此同时,您必须使用一个非常简单的 <customErrors>部分如下:

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />

关于security - MVC - CustomErrors 在设置 redirectMode =“ResponseRewrite” 时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3779581/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com