Is it really worth migrating from ASP to ASP.NET? No doubt it is! This is a really easy question to answer and you should do it ASAP (if you forgive me the slight pun). In this article, I will cover some of the reasons why you should migrate and try to help the reader to decide and see the advantages of migrating to ASP.NET.
1. Development tools – normally an ASP developer will use such tools as Visual InterDev, Dreamweaver, Ultradev, Homesite, Adobe Go Live and, why not, the good-old Notepad (that has never crashed!!!), EditPad, in sum, the tool you know best. However, you will need to know at least HTML e VBScript to get by. In some cases, JavaScript is used, Perl, DHTML, among other tools. Now, with ASP.NET you can use VS.NET (which you can find in three versions Professional, Developer and Architect) or for those who’d rather not put their hands in their pockets, they’d use Web Matrix. Notice that in a single tool you have at your disposal all the tools you need to develop all the topics I discuss in this article
2. Script x Compiled – with VBScript, the HTML and JavaScript codes are called scripts. When a page is called on the server, the ASP library reads each line step by step, interprets the code, build the virtual HTML and send the information to the browser which requested the information. On ASP.NET the pages are compiled onto DLLs and thus, no matter how simple the page is, it will be around 25% faster than normal ASP. Now, imagine you have a large application where the processing of simultaneous scripts requires performance? You can kiss goodbye to ASP. As far as language is concerned, you can choose any of the native languages supported by the DotNet Framework. On VS.NET you can choose between VB.NET, C# and C++ with the default installation option.
3. Variables – In VBScript the explicit declaration of variables is not mandatory; in ASP.NET all variables must be declared. In VBScript if you declare a variable, say, Dim Test, there is not data type for this variable and it is, thus, treated as a Variant, in other words, it takes any value. In ASP.NET all variable must be declared according to its data type (Dim name As String). This is critical for code execution, allowing us to know exactly what data type it is and, when necessary, we can convert the data type by using one of the data type conversion functions.
4. Development models (splitting design and code): this is one of the simplest things for those entering this new environment. In ASP you must insert the VBScript inside the existing HTML, which cut up the pages making it harder to maintain them. Who never needed to change an ASP page layout? In ASP.NET this torture has ended. Now, there are two separate files, one for the layout another one for the code, where a line links both files. This is the so-called Code Behind. Thus, design can be changed without any problems. In parallel the programmer can develop the code. It is important to point out that it is also possible to develop inserting the code directly onto the design page.
5. New Controls: ASP.NET comes with new controls that make it easier to create web pages, mainly when it is necessary to publish database contents. Some of the controls are: DataList, DataGrid and Repeater. In ASP you normally build tables by merging HTML code with VBScript, you then build a loop that reads from the Recordset. If you use the DataGrid, for example, you can do all this with only two lines of code. All you have to do is to define the DataSource property and then use the DataBind method. It is really amazing how clean ASP.NET pages are, since the amount of code needed is drastically reduced. Data validation has never been easier and with ASP.NET you can use the Validator control and configure it to suit your needs. Another control that will help web-developers is the Calendar control, which can be configured to receive one or more set of dates.
6. Debug: To begin with, you’re already familiar with the two commands: Response.Write e Response.End. Believe it or not, this is the best way to debug errors on ASP. With VS.NET we are in another world where you can set breakpoints, execute the page on a browser and when the point is located, VS.NET shows the code forcing a momentary pause in the execution. From this point onwards you can check the contents of your variables and accompany, step by step, the execution of your code. It is worth pointing out that it is often good to run through the code simply to ensure it is executing well.
7. Treating Errors: The only way to treat errors in ASP is through the instruction On Error Resume Next. This does not allow you to identify the error type. In ASP.NET this has been totally restructured with Try-Catch-Finally, where it is possible to identify any error and even customize the error messages.
8. Components: “componentization” is really an excellent tactic for developing web pages, which allows breaking up the application into layers (1, 2 or 3). The advantages are enormous when it comes to security, portability, maintenance, code reuse, etc. Normally ASP pages consume components created on Visual Basic of ActiveX. The question here is not the advantages of layered development, but the use of components. In ASP.NET using components created for the .NET framework is extremely simple, all you have to do is to create the references and consume them on the pages. It is important to point out that the components developed for the .NET framework do not require the component to be registered, or rather; there is no registry for the component. It is simply achieved by copying (XCopy) of the DLL onto the destination folder. ASP.NET pages will also consume components created on Visual Basis or any other ActiveX. However, this will be executed on an environment which is not managed by the . Framework, that is, any error generated at the component level, the operating system is responsible for that, while in a .Framework managed environment, any error is isolated at the operating system.
9. External components: Some well-known components such as Upload, e-mail component, ad-Rotator and Calendar are native to ASP.NET. Thus, you do not need to purchase any additional components. For example, you can Upload a file with a few lines of code.
10. ADO x ADO.NET: Here there have been major changes. In ASP the only concept available is the recordset. Under ASP.NET the recordset no longer exists and it has been superseded by the DataSet, which is also raised in the memory. However, you can build a DataTable, DataView, DataReader and DataAdapter. Notice that for each scenario you will use a specific method. The data access can be done through such drivers as OleDB, SqlClient, Oracle or ODBC. If you use SQL Server 7 or 2000, you should use the SqlClient which has been created specifically for this task. All the structure generated by ADO.NET is XML based, but this is very transparent to the developer.
Thus, with so many new additions, what is the best way to harness the necessary know-how at your organization? How to get your team up and running? I have always been in favor of customized training in order to take advantage of the experiences and know-how of developers already within organizations. By doing so, the learning curve is flat and not steep in such migrations. Some people would prefer to get to grips with these things through books and dedicated literatures; but no matter how good you are at self-teaching the time required will be lengthier. On the other hand, technical seminars and multimedia training kits are always welcome.
The most important thing right now is that a new era has dawned and you are right in the middle of it with no turning back. I’ve been there and I certainly do not look back. I have no doubt you will not regret when you take this next step.
No stress. Think .NET
This article was originally published in www.linhadecodigo.com.br