Our blog has the latest information and news
back to blog home printable version Save a WORD document

Creating a Classic ASP consumer in our new CMS

Posted on 4/16/2009

Introduction

This article is an excerpt from our full article on our ASP.NET MVC rewrite

We recently rebuilt our Classic ASP content management system using ASP.NET MVC. One of our biggest challenges the amount of time and money we had in relation to the amount of Classic ASP functionality that needed to be migrated. Converting all that Classic ASP code was literally impossible with the time and money we had. Our strategy was to convert as much as we could but then we thought it would be nice if we had a way to consume or "suck in" Classic ASP pages into the ASP.NET master page templates. This article describes how we did that

 

Use of existing Classic ASP Code

Brick River has an extensive base of existing Classic ASP code. This needed to be presentable using the new framework without requiring a complete rewrite. At the same time, changes to Master pages and page views should be reflected in the classic ASP sections of the site.

Consume Classic ASP

The processing of classic ASP code using the framework happens as follows.

  1. {page}.asp is defined as a route at application startup. This preserves the existing URL so as not to break links, etc. The page name, without the .asp extension, is passed to the controller action.
  2. The request is routed to the Classic controller Page action. This controller action is also available as /classic/page/{page} allowing friendly URLs to optionally point to classic pages.
  3. The controller looks at the ASP.NET session to see if we have saved a classic ASP session ID.
  4. An Http Web Request is created. It's cookies are set to provide the session ID, if found. The page entity is also forwarded to the request for form processing.
  5. The classic ASP application is called.
  6. The Http Web Response now has the output from the Classic ASP page.
  7. The Classic ASP Session ID is retrieved from the response cookie and stored in the ASP.NET Session for future reference.
  8. The controller now has the page content. It can preprocess the page if necessary before dispatching it to the view.
  9. The controller dispatches the content to the view. This can now be rendered using the current site design.

This method will allow us to gradually move the application to ASP.NET MVC over time.