【发布时间】:2011-11-30 22:09:55
【问题描述】:
您好,如果响应是 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);
}
}
更新
目前尝试过
(Response.Status == "404 Not Found")
(Response.Status == "404")
(Response.StatusCode == 404)
【问题讨论】:
-
你的意思是把
Response.Redirect(notFound );? -
啊,发帖时打错字了,但还是有问题。谢谢
-
你能试试吗(Response.Status == 404)(我不确定它会起作用,但试试看)
-
试过了.. 仍然没有找到它,它是 (Response.StatusCode == 404) 因为 (Response.Status == "expects a string") 并且也尝试过 (Resonse.Status == "404") 并尝试过 (Response.Status == "404 not found") 都不起作用
-
(Response.status == HttpStatusCode.NotFound)
标签: c# asp.net redirect http-status-code-404