1. Computing
An introduction to ASP.NET programming with Delphi. Configuring do I set up the Cassini web server?
What is ASP.NET from the perspective of a Delphi developer? How do I set up the Cassini sample web server.
 Join the Discussion
"Post your views and comments to this chapter of the free ASP.NET Delphi Programming Course"
 Related Resources
• A Beginner's Guide to ASP.NET Programming for Delphi developers.TOC

 Elsewhere on the web
• MS's ASP.NET "home"
• Borland Delphi for .NET "home"
• aspxDelphi.net

Welcome to the first chapter of the FREE online programming course:
A Beginner's Guide to ASP.NET Programming for Delphi developers.
What is ASP.NET from the perspective of a Delphi developer? How do I set up the Cassini sample web server?

OK, let's make a fast start.
ASP.NET is the .NET programming environment for building Internet applications with an HTML front end. Delphi 8 is pure .Net, and fully supports ASP.NET development. If you are familiar with the "old" ASP, I'll have to disappoint you and tell that ASP is nothing like ASP.NET. Since you are, as a Delphi developer, familiar with RAD and object oriented programming using properties, methods, and events, you will find the ASP.NET model for building rich Web applications very straight forward. Some Delphi powered asp.net solutions are already available, like Web Portal and Web Store, both available from aspxDelphi.net

Asp.Net comprises several different technologies, including Web Forms (i.e. Forms in standard Win 32 development), Web Services, Web server controls (that is FCL for Web), HTML controls and validation controls. When all these technologies work together they provide a developer with the ability to create robust, powerful, maintainable and scalable Web applications.

Let's see what ASP.NET is all about in a few simple statements:

  • Web Forms: the heart and soul of an ASP.NET application. A typical Web Form consists of HTML elements and asp.net web server controls. These controls allow you to rapidly build a Web Form out of reusable built-in or custom components, simplifying the code of a page. ASP.NET Web Form pages are text files with an ".aspx" file name extension. When a user first accesses the Forms page over the web, ASP.NET generates a compiled DLL file that then dynamically generates HTML output for browsing.
  • Web Server Controls: the WebForm building blocks. Server controls are declared within an ".aspx" file using custom tags or intrinsic HTML tags that contain a runat="server" attribute value. Web Controls are much like the standard Delphi VCL control, it's just that they "render" an HMTL output. Web Controls have properties, events and methods, they implement interfaces and can be extended.
  • HTML Controls and HTML Server Controls: "standard" HTML blocks. HTML elements in ASP.NET closely match many common HTML elements found on web pages (table, span, div, input, etc). By default, HTML elements on a Web Form page are not available to the server; they are rendered as entered on a Web Form. By converting HTML elements to HTML server controls (adding a runat="server" attribute), you make them server-side aware.
  • User controls: provide a mechanism for creating reusable ASP.NET code "pagelets". User controls are like Web Forms, just without the beginning and ending page tags, and are text files with an ".ascx" file extension. Think of standard Delphi Win32 TFrame objects when thinking ASP.NET User Controls (for the moment).
  • Validator controls: client side (no "postback" - "roundtrip" to the server and back) validating functions. Validation controls allow you to test user input in ASP.NET web (html or user) controls
  • ADO.Net: let's just say that ADO.NET is designed as a back-end data store for all .NET programming models, including Web Forms, Web Services, and Windows Forms.
  • Web Services: XML based application components. An XML Web service provides elements of functionality, such as application logic, and is accessible to any number of distributed systems using XML-based messaging; ubiquitous Internet standards, such as XML and HTTP.
Much more general info about ASP.NET can be found here: Asp.Net QuickStart - these pages are targeted mainly at VB.NET and C# developers, but you could/should read some general ASP.NET topics. You can also read "A comparative review of EWF, IntraWeb and ASP.NET".
But I need a Web server! MS's IIS? Cassini?
ASP.NET is server side web development, which means that you need to have a web server in order to build and debug asp.net applications. By default, Delphi 8 sets MS's IIS as your developing/running/debugging platform. If you do not have IIS installed on your development machine, you can use the Cassinni sample web server that ships with Delphi 8. The Cassini Web Server is a sample web server written in C# (.Net), it demonstrates hosting ASP.NET pages using the ASP.NET hosting APIs.

Cassini web serverAs said, Cassini comes with Delphi 8, and its code can be found in "C:\Program Files\Borland\BDS\2.0\Demos\Cassini" depending on your installation folder structure. Don't be frightened with the C# code, after all we need Cassini only as a sample web server for our Asp.Net applications (if you do not have IIS installed, that is).
To install Cassini, you'll need to run the build.bat file in the Cassini folder. If you simply run the build.bat you could end up with the "'csc' is not recognized as an internal ..." error - because it assumes that you have both the .NET framework's and the .NET SDK's \bin directory in your environment's path (in order to access the csc C# compiler and the gacutil.exe).
The solution is to add "C:\Windows\Microsoft.NET\Framework\v1.1.4322" and "C:\Program Files\Microsoft.NET\SDK\v1.1\bin" in the System's Path variable, or to change the build.bat. Note that the exact directory path depends on your machine settings (do a search for "csc" and "gacutil").

Once you have Cassini running, you can choose Cassini as the web server via the Project Options. We'll talk more about that in the later chapters.

The "original" Cassini project can be located here: Cassini Web Server from Asp.Net

What to expect
Now that we have agreed on what is ASP.NET and we have all the tools we need, that is Delphi 8 and a web server we can start building dynamic web ASP.NET applications using Delphi.

What we are up against in this course is the BDSWebExample ASP.NET demo that ships with Delphi. The BDSWebExample can be found in "C:\Program Files\Borland\BDS\2.0\Demos\DB\ASPPortal\BDSWebExample" on a default install. Your Guide is the author of that demo - and naturally the developer to "expose", and explain the code!
Note: make sure you download the new version of the code (and save it in "C:\Inetpub\wwwroot\BDSWebExample")!

BDSWebExample running in IE

The BDSWebExample shows how to build a "CodeCentral"-like web site using ASP.NET. It supports user login, product submission, browsing, page view statistics, banner (adverts) system, etc. You can find many nifty code samples here: how to use (web) forms authentication, bind data aware controls, build user controls, create inherited web controls (custom DataGrid + dynamic ItemTemplate; EditItemTemplate, custom DataList), how to use validator controls, JavaScript, etc...

As you can see we'll have much work to do ... until next time, I suggest you to take a quick look at an example of creating content driven dynamic web sites with Delphi 8 and ASP.NET as simple as "click-and-go" : visit aspxDelphi.net.

To the next chapter: A Beginner's Guide to ASP.NET Programming for Delphi developers
If you need any kind of help at this point, please post to the Delphi Programming Forum where all the questions are answered and beginners are treated as experts.

A Beginner's Guide to ASP.NET Programming for Delphi developers: Chapter 2 >>
>> Setting up the BDSWebExample Delphi 8 (ASP.NET) demo application

©2014 About.com. All rights reserved.