Nik's Technology Blog

Travels through programming, networks, and computers

Migrating from ASP to ASP.NET 2.0

I've pretty much finished migrating my personal website from classic ASP to ASP.NET 2.0. In the end I decided to keep certain pages using ASP (Active Server Pages) technology (more on that in a moment), the majority of the pages however have been migrated.

Minimise Page Rank Loss

While I wanted to bring my site up-to-date I also didn't want to lose too much Google Page Rank in the process, and make people's bookmarks and RSS blog subscriptions stop functioning. The reason the pages have to change URLs is that ASP.NET pages use the extension .aspx, compared to ASP's .asp 3-digit extension. So my portfolio.asp page for example has become portfolio.aspx.

Analysing what can be Migrated

My blog area uses Google's Blogger as a CMS, so this area hasn't had to change, although prior to using Blogger I had previously built my own blog engine and this has remained as is.

The most popular part of my site is my Cisco CCNA section. Apart from the new menu page, the other pages have half-decent Page Rank and a few pages also have DMOZ entries, so those have had to remain ASP too.

Using 301 Permanent Redirects

All the other pages however have been migrated. When you now visit those old pages (from SERPS or old links) you'll get HTTP 301 redirected to the new ASP.NET pages. Because I'm on a shared server with no access to IIS (Internet Information Server), I essentially had to hard-code ASP 301 redirects on all the ASP pages that have moved, redirecting users to the new versions.

Update Robots.txt

The next step in the process was to include those old ASP pages in my robots.txt file and log-in to the Google Webmaster console to expedite the removal of those old pages from the Google index using the URL Removal tool. If you haven't already accessed Webmaster tools I highly recommend you log-in and verify your site.

Spidering as a Final Check

Next, I made sure all navigation menus and links to the old pages under my control were pointing to the new versions. This meant updating my Blogger template and republishing, updating my old ASP navigation include files and crawling my site using XENU link sleuth to check for any I had missed.


Moving my content over to ASP.NET has been fairly straight forward due to the small number of pages, my Tools and Portfolio pages display data stored in XML files, so it was just a case of using XmlDataSource controls to pull the information onto the pages. My homepage picks up the latest entries in my Blogger Atom feed using XSLT, and my contact form uses basic ASP.NET form and validation controls.

Increased Functionality

While migrating my content I thought I'd use the caching feature built-in to ASP.NET to allow me to display my latest ma.gnolia bookmarks on my site, so I ended-up creating a Bookmarks page, which fetches my ma.gnolia lite RSS bookmarks XML file, either from or my cache. The cache doesn't hold my data for as long as I stipulate, but I'm assuming this is because I'm on a shared server and the cache is dropping it to free resources.

Contact forms, SPAM relay email and the CAPTCHA

Back in January this year I decided enough-was-enough with increasing amounts of automated SPAM coming into my inbox and originating from my site. I decided to do something about it. My contact form has been attracting lots of SPAM bots which were trying their best to relay their SPAM through my site.

My form has always had the To: and From: fields hard-coded however, so I doubt anything ever got relayed, but they all got sent to me anyhow.

As a result I now verify that the form was actually filled in my a HUMAN each time the form gets sent! I've built an ASP CAPTCHA function to achieve this (Completely Automated Public Turing test to tell Computers and Humans Apart), more about CAPTCHAs here.

Accessibility and CAPTCHAs

There are however down-sides to this SPAM free existence. CAPTCHA images in the form that I am using are inherently inaccessible, so I intend to use another system in conjunction with my image CAPTCHA as used my Matt Cutts on his blog.

Generic web form emailer using FOR EACH and CDONTs

The ASP code below will loop through all the requested form fields submitted to it and send a CDO email from your server to your email account with the values of all those fields.



Dim cdoMail, Recipient, Subject, Redirect, Sender, item, MailText

Recipient = ""

Subject = "Enquiry from website"

Redirect = "index.html"

Sender = ""

  MailText = "Email received from my website"

for each item in request.form

  MailText = MailText & item & ": " & request.form(item) & vbcrlf


Set cdoMail = Server.CreateObject("CDONTS.NewMail")

  cdoMail.From = Sender

  cdoMail.To = Recipient

  cdoMail.Subject = Subject

  cdoMail.Body = MailText


Set cdoMail = Nothing

Response.Redirect Redirect


For more information about the FOR EACH vbscript statement please see my previous post below.

Simple ASP Form Collection with FOR EACH

The code below shows how to grab form submitted data from a page by looping through all submitted form items using the FOR EACH vbscript code.

Note: The submit button does NOT have a NAME attribute, this is so it doesn't appear within the fields on the process page.

The code can be altered to loop through query string data aswell. Simply replace "for each item in request.form" with "for each item in request.querystring".


<html><head><title>Lazy Man's Form Collection using FOR EACH in ASP</title></head><body>

<form action="form_collection.asp" method="post"> <input type="text" name="Name">

<input type="text" name="Address">

<input type="text" name="Country">

<input type="text" name="Age">

<input type="submit" value="submit">




<html><head><title>Form Collection</title></head><body>


for each item in request.form

response.write "<b>" & item & ":</b> " & request.form(item) & "<br>"