views:

415

answers:

5

I'm looking at converting a web site from classic ASP to ASP.NET. I'm thinking of doing an agile style approach and providing deliverables as quickly as possible and so am thinking of doing a line by line conversion and creating "bad" ASP.NET and have it all in the ASPX file for phase 1 and get that working. That, I figure, will be the fastest and safest (i.e. preserving identical functionality). The next phase would be to split the code out into codebehind and multi-tiers.

I plan on replacing the VBScript in the ASP files with C# in the ASPX files.

So apart from general comments about what I'm planning on doing (which I welcome) the specific question that I have is: Are there any helper functions out there that wrap the VBScript functions from ASP to a C# equivalent that someone's already done?

So I'd be looking for a C# file (library) that has wrappers like:

string Mid(string txt,int start,int length)
{
  return txt.SubString(start, length); // or is it start - 1?
}
double Abs(double num)
{
  return Math.Abs(num);
}
A: 

If using ASP.NET MVC is an option for you, I'd take a look at that first. I would think it would be a much easier translation than trying to go from a scripting language to WebForms.

Daniel Schaffer
+5  A: 

Look in the Microsoft.VisualBasic namespace to get access to the old VBScript/VB6 functions. You can use them directly from C#.

Additionally, you're in for a shock. ASP.Net uses a different compiler model, and so some of the things you did in Classic ASP aren't allowed at all in ASP.Net. Include files is the big one that comes to mind-- all of your supporting code (code outside of the *.asp file for the page itself) must be re-thought to support the new model.

Joel Coehoorn
+2  A: 

I don't think a line-by-line approach is a good idea - you'll just end up with a bunch of bad code that you'll still have to refactor. That doesn't sound very Agile to me either.

I'd try breaking the site up logically into modules, and then try rewriting specific pages or modules as ASPX. For example, if the site has an admin section, maybe you could just rewrite the admin portion. Then repeat for the next section. This could be done iteratively for each section until you're done.

Jason
+1  A: 

I agree with the comment by Jason, and would like to also point out a higher level issue that you'd have to address, if you haven't thought about it already.

Does your classic ASP site make use of session variables to manage state between pages? If so, have you thought about how you're going to share session state between ASP and ASP.NET? Classic ASP and ASP.NET implement session state in different ways, so you will need methods to transfer between the two.

Smaller applications may be easier to "convert", but if you've got a large app that makes heavy use of session variables, you may want to think about other options.

Don
A: 

I don't think you gain anything by redoing the site as-is in .Net. Implementing it properly will be so radically different than what you'll start with in .Net that it just seems like wasted effort. Furthermore, it will be very difficult to write unit tests if you implement everything in .aspx pages without even code-behind.

I would aim for an MVC conversion. If you do port it over as-is, at least investigate master pages, that should save you some headaches.

RedFilter