This site contains older material on Eiffel. For the main Eiffel page, see

An Eiffel for .NET Web Service:
The power of .NET, Eiffel, ASP.NET and Design by ContractTM

This live demonstration showcases the use of Eiffel for .NET and Eiffel's Design by ContractTM to build reliable web services. You will find:

  • A running demo.
  • Detailed explanations.
  • The entire source code.

The demo runs on the Web, but you will also learn how to transform it almost instantaneously into a client-server system running, without a browser, on a graphical Windows client.

About the Demo

The demo is a registration service for a conference. It provides two main pages:

  • For conference attendees: A registration page.
  • For the conference organizers: A status page, showing the current state of registrations.

In this demo you will be both "attendee" and "organizer": you can register yourself as an attendee using the registration page; then moments later you can use the conference management page to see the updated attendee list including yourself.

This is a fictitious registration and no information is kept permanently. (The information for the last few registrations will temporarily appear on the "organizers" page, so that you can see it as part of the demo. Do not enter any personal information that you wouldn't want others to see, even for a short while.)

Running the Demo

First, see how the process works in a non-erroneous case:

  • Go to the registration page and fill in all the fields. Click the "Register" button after you have filled the form.
    • As noted above, the only use of this information is for the demo. No information will be retained for any other purpose.
  • The confirmation page will appear. (If it doesn't, it means you have not filled in all the fields; please go back to the registration page and fill in the missing fields with valid information.)
  • From the confirmation page, click on the link See Report
  • The Report page contains two tables that list the content of the database -- the recently entered "registrations". Your registration appears at the bottom of both tables. The page automatically refreshes every five seconds.

Now let's see what happens in the case of an error:

  • Go back to the Registration page and fill in all the fields except the field "First Name".
  • Click the "Register" button. An ASP.NET error page appears showing a contract violation in the Eiffel for .NET component.

Finally, you should read more about the demo to understand the combination of mechanisms, from Eiffel for .NET, ASP.NET and .NET, that makes these results possible through simple programming. You will also find out how the technology lets you transform this Web-based system into a client-server system running natively without a browser.

Error Handling

The precondition violation in the last step indicates a bug in the ASP.NET page: the contract of the Eiffel component requires the value of "First Name" to be non-empty.

With a well-designed page, this error will not occur during Web browsing, so no user will ever see the page showing the precondition violation. The page will only appear during testing, enabling the Eiffel for .NET developers to detect unhandled erroneous cases, and provide users with the appropriate pages or popups in these cases. The resulting, corrected page will only call the component when the values are valid, i.e. they satisfy the the preconditions on the Eiffel features.

During development, the contracts, preconditions in particular, provide invaluable help for the developers:

  • They work as a specification for the ASP.NET page writer.
  • They provide built-in documentation. ISE Eiffel tools will automatically extract the contracts from a class and produce a pretty-print (plain text, rich text format, html etc...) that can be handed to the people that will reuse the Eiffel class.
  • They support the testing and debugging process. A precondition violation signals an improperly handled abnormal case; a postcondition or contract violation signals a problem in the Eiffel for .NET component itself.

For a general introduction to Design by Contract and its application in Eiffel see the introductory paper on Design by Contract.

Contracts are particularly powerful for the kind of distributed systems made possible by the Web. The combination of Eiffel for .NET and ASP.NET provides developers of e-commerce applications with unique tools to produce the reliable, scalable, ambitious applications required by today's enterprise customers.

Reading the Sources

You may download the full source for both the Eiffel for .NET classes and the ASP.NET pages from: