What is ASP.NET and Why Should I Use It?
Written by Nick Dunn published 8th Mar 2006 | Comment on this article
ASP.NET is a big step for web developers. It boasts more speed, functionality and power than ?classic? ASP 3.0, and here?s why.
ASP.NET, or indeed the entire .NET framework, is Microsoft's new development platform. The benefits of this new technology are boasted elsewhere (see links at the end) so I'll focus on the web development side of things.
What is ASP.NET?
Put simply, it is the logical progression from ASP 3.0. It is the new development environment in which to create even more powerful web applications.
What's different from Classic ASP?
A better question could be to list the similarities, of which there are few. Arriving at ASP.NET from an ASP history of about 3 years I found migrating a struggle. Here's why.
"Real" programming
ASP.NET uses 'real' programming. Classic ASP used a sanitised version of Visual Basic 6 (VBScript) as its primary language. However, ASP.NET can be written in a variety of standard languages, including VB.NET, C# and J#. Although VB.NET is similar to VBScript used in Classic ASP, it takes a lot of getting used to. Thankfully we're now using strongly-typed, object oriented program. With minimal effort you can write a web application and a Windows application using almost identical code.
Object oriented (OO)
Whassat? Let's put it this way. OO makes your life so much easier. I had attempted to build OO applications using Classic ASP with moderate success. For an example of OO Classic ASP, download the demo of Helm and take a peek at the ASP! VB.NET (my language of choice) is entirely OO. At last! At first I didn't understand the concepts or where I could use classes and objects in my code, but after writing a single ASP.NET page realise you use objects without realising.
Coding styles
There's a huge paradigm shift away from inline scripting (yuk) to managed 'code behind', whereby all programming business logic is written in separate class files for each page, and compiled into a DLL at release. Not only does this increase speed because the code is compiled once only (and not at runtime like in Classic ASP) but your logic is separated entirely from the page presentation.
ADO.NET
This is the progression from ADO (Active Data Objects) which provide objects for streamlined data access. At first the terminology confused me and put me off connecting to a database at all! You may find yourself in a sea of DataAdapters, DataReaders, DataLists and DataGrids. Don't panic, as it will all become clear with practice. However this is yet another paradigm shift. No longer think of your data as recordsets, but as disconnected tables. It's a subtle difference, but ASP.NET's controls allow you to do more complex manipulation of your data.
Bring on the DataGrid
This one control is enough to convert anybody to ASP.NET. In the past when you've wanted to write a recordset into an HTML table, I bet you've written a loop somewhere in your HTML to iterate through records and write out a variety of tags. What a mess. The DataGrid control replaces this method. Just create a DataGrid control using one line of pseudo-HTML in your page, and populate it with data using VB.NET code (called 'data binding'). I won't go into the code, but it really is that simple.
Can I do the same things using ASP.NET than I do currently with ASP?
When I first began using ASP.NET I wad constantly thinking of the way I approached problems using Classic ASP and recreating this using ASP.NET. Although innevitable, try not to. It's almost like relearning how to develop applications. If you want to display records in a table on your page, look for the DataGrid control. If you want to persist input form data when the page is refreshed use form controls and the 'view state' functionality, not mucking around in your HTML adding ASP code to write out requested values!
So how can I start?
I've found the best way to get to grips with ASP.NET is to be thrown into the deepend as I was. Although it took two weeks to develop an application using ASP.NET which would have taken three days using Classic ASP, I learned from scratch in that time. I'm no professional developer - the only 'programming' I have ever done before is VBScript. So how hard can it be!
Well, I did have help. There are loads of websites and books to help, and I can recommend those which I have used.
Resource sites
- Microsoft MSDN has increasingly stolen my time. Not only is it informative but there's just so much there. Check out the .NET show or the DotNetRocks! radio show for geeky chat.
- ASP.NET homepage is a great place to start. The forums, especially the Beginner forums have helped me out many times!
- 411asp is ASPin.com but for .NET! Say no more
Software
You don't need expensive software to built ASP.NET applications. Microsoft have their Visual Studio tool which is nothing short of amazing and I highly recommend it. However there is a free version called Web Matrix which is similar to Visual Studio, but less powerful. There's everything you need to begin creating web applications though. You can also still hand-code your code if you wish. Notepad will do just fine, but Visual Studio's intellisense makes code writing less stressful.
Books
There are loads of books to aid beginning ASP.NET development. I bought several and found them to be useful, but uninspiring. The best buy is the third in the list.
- Beginning ASP.NET with VB.NET (Wrox) is big to say the least. Gives a really good breakdown of the VB.NET language which was a great help. Once they've got you understanding the language they explain 'controls', OO programming, and how to construct pages. Very little on code behind, so look further afield for more and don't get into the habit of inline scripting again!
- Teach Yourself ASP.NET in 21 days (Sams). The ASP version of this book got me hooked all those years ago. However this version didn't have the same effect. Although logical and explanatory, the code samples are uninspiring, but it still provides an overview of ASP.NET
- Programming ASP.NET (O'Reilly) is by far the best. It's not a beginner's guide, but starts off with the basics (although it assumes previous knowledge of ASP and web development practices). It's chunky, contains both VB.NET and C# code samples, and gives practical examples to demonstrate uses of code. Definitely worth a buy as a reference.
Conclusion
I've tried to lay down some of the things that I've discovered personally when migrating to ASP.NET. Apologies if the structure isn't as logical as it could be, but it's such a large topic, it's not easy to cram everything in. I hope it helps in persuading you to take the leap of faith and start to play with ASP.NET. You won't regret it, and more to the point, you'll never look back.