Hello World the ASP.NET Way
You willcomplete this evolutionary journey by changing your Hello World web page from ASP to ASP.NET. A key difference in ASP.NET is that you no longer use interpreted languages but instead use compiled languages. Typically, ASP.NET applications are built using either C# or VB.NET. In either case, the performance will be a great improvement over script.
Note
A significant theme of this book is that the choice between C# and VB.NET is purely syntactic; you can express any ASP.NET programming idea in either language. We suggest you write in whichever language you’re more comfortable with. The transition from VBScript to VB.NET may be slightly easier than to C#, but much of the Microsoft and third-party documentation is in C#. In this book we will show most examples in both languages, though we confess to a slight preference for C# because it is a bit more terse.
For a full exploration of VB.NET, see Programming Visual Basic .NET , by Dave Grundgeiger (O’Reilly), and for C#, see Programming C#, by Jesse Liberty (O’Reilly).
Example 2-3 shows
vbHelloWorld1.aspx in
VB.NET, and Example 2-4 shows the same program in
C#.
Example 2-3. Code listing for vbHelloWorld1.aspx
<%@ Page Language="VB" %>
<html>
<body>
<h1>Hello World</h1>
<h1>ASP.NET Style</h1>
<h2>Using VB .NET</h2>
<br/>
<h2>The date and time is <% =DateTime.Now( ) %>.</h2>
</body>
</html>Example 2-4. Code listing for csHelloWorld1.aspx
<%@ Page Language="C#" %> <html> <body> <h1>Hello World</h1> <h1>ASP.NET ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access