gpt4 book ai didi

c#-4.0 - 如何在 DotNetNuke 模块中抛出 404

转载 作者:行者123 更新时间:2023-12-02 02:17:48 26 4
gpt4 key购买 nike

我想从我的模块中抛出一个 404 file not found 异常,但是每个异常都被 DNN 捕获,并且没有显示我的 404.aspx 页面(仅来自 DNN 的错误页面)。

在我的 web.config 中,我添加了:

<httpErrors errorMode="Custom" defaultResponseMode="File">
<remove statusCode="404" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="ExecuteURL" />
</httpErrors>

&
<customErrors mode="On">
<error statusCode="404" redirect="~/404.aspx" />
</customErrors>

打开不存在的页面时效果很好。但是尝试对我的模块做同样的事情并没有给我同样的结果......

我尝试了以下但没有成功:
throw new HttpException(404, "Not Found");

最佳答案

这样做:

Response.StatusCode = 404;
Response.End();

关于c#-4.0 - 如何在 DotNetNuke 模块中抛出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688438/

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