use*_*502 5 c# asp.net redirect http-status-code-404
您好我正在尝试重定向,如果响应是404,但它没有按预期工作,您可以专家看到问题吗?它仍然是通用的404
在我的Global.asax中
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (Response.Status == "404 Not Found")
{
string notFound = "~/custom_notfound.aspx";
Response.Redirect(notFound);
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
到目前为止尝试过
(Response.Status == "404 Not Found")
(Response.Status == "404")
(Response.StatusCode == 404)
Run Code Online (Sandbox Code Playgroud)
您还可以使用web.config customerrors部分 - 如此处所示
例如,在system.web部分,
<customErrors mode="On" defaultRedirect="/custom_error.aspx">
<error statusCode="404" redirect="/custom_notfound.aspx" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5501 次 |
| 最近记录: |