【发布时间】:2013-11-26 14:07:52
【问题描述】:
如果 HttpError 是 404,我正在尝试重定向页面 它在本地主机上运行完美,但在 Live 站点上却不是。
这是我的代码
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
HttpException serverError = Server.GetLastError() as HttpException;
if (serverError != null)
{
int errorCode = serverError.GetHttpCode();
if (errorCode == 404)
{
Server.ClearError();
if (Request.Url.ToString().Contains("contact.php"))
{
Response.Redirect("contact-us.aspx");
}
}
}
}
谢谢。请告知如何让它在现场工作,
【问题讨论】:
标签: c# asp.net .net url-rewriting