RedirectPermanent后面的VB代码不起作用

时间:2014-08-04 00:06:39

标签: asp.net vb.net url-redirection

新手问题在这里。我正在将ASP.NET站点重新设计为4.0,并且需要重定向一堆旧URL。我想在代码隐藏文件而不是逐页的基础上做到这一点。有人能告诉我为什么这不起作用吗?

Protected Sub Application_BeginRequest(sender As Object, e As EventArgs)

If Request.FilePath = "/olddirectory/oldfile.aspx" Then
    Response.RedirectPermanent("index.aspx", True)
End If


End Sub

提前谢谢。

1 个答案:

答案 0 :(得分:0)

您当前的重定向是尝试转到/olddirectory/index.aspx,如果不存在,则会产生404(您没有指定错误)。如果您改为

If Request.FilePath = "/olddirectory/oldfile.aspx" Then
    Response.RedirectPermanent("/index.aspx", True)
End If

它将重定向到应用程序根目录中名为index.aspx的页面。

相关问题