Forum Moderators: open
I've not actually seen anything inherit within .NET that would reduce its viability for SEO. What I have experienced, is poor deployment strategies when converting ASP Classic to ASP.NET. Below is the Page Load event I use for a custom 404 page when converting sites.
The SendMail is a custom library method that sends out e-mail. You can insert your own method there. This code will handle 404 errors, make a determination if the user was looking for a .ASP page, attempt to find the new ASP.NET page and use a 301 redirect to send them to it. It also reports referring sites that have links to the old pages. Hope it helps with your .NET projects.
-Response
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ErrQS As String = String.Empty
Dim ErrScript As String = String.Empty
Dim NewPage As String = String.Empty
Dim Target As String = String.Empty
Dim AppPath As String = HttpContext.Current.Request.PhysicalApplicationPath
' Testing check
If (Request.QueryString.Count = 0) Then Return
' Parse out script name
ErrQS = Split(Server.UrlDecode(Request.QueryString.ToString), ";")(1)
ErrScript = Replace(ErrQS, ":80", "") ' clean out Port 80 text
ErrScript = Replace(ErrScript, "[This Site's URL]", "", , , CompareMethod.Text) ' clean off HTTP and domain text
' ASP Classic Test
If (Right(ErrScript, 4).ToUpper = ".ASP") Then
' ASP Classic file referenced
' Attempt to locate new ASP.NET file
Target = AppPath & Replace(ErrScript, "/", "\") & "x"
' New Page exists test
If File.Exists(Target) Then
NewPage = ErrScript & "x"
Response.Status = "301 moved permanently"
Response.AddHeader("Location", NewPage)
End If
End If
' External referrer test and e-mail alert
If (Request.UrlReferrer IsNot Nothing) Then
If Not (Request.UrlReferrer.Host.Equals(Request.Url.Host, StringComparison.InvariantCultureIgnoreCase)) Then
Dim Subject As String = "Invalid Link from Referrer"
Dim Body As String
Body = "Invalid external link:" & "<BR/>"
Body = Body & "Site: " & "[Your Site Name Here]" & "<BR/>"
Body = Body & "Link: " & ErrScript & "<BR/>"
Body = Body & "Referrer: " & HttpContext.Current.Request.UrlReferrer.Host & "<BR/>"
SendMail("[SMTP Server]", "[To Address]", "[From Address]", Subject, Body)
End If
End If
End Sub