By Tim Posey

Introducing ASP.NET and the .NET Platform

By Tim Posey

This is an excerpt from our latest book, Build Your Own ASP.NET 4 Website Using C# & VB by Cristian Darie, Wyatt Barnett & Tim Posey.

By now, ASP.NET is one of the most popular web development technologies on the planet. The first version was released in 2002, and since then, Microsoft has continued the tradition of releasing a powerful web development framework that allows web developers to do more with less. ASP.NET has experienced rapid growth among the established corporate world, as well as becoming the choice for many freelance developers. ASP.NET has many advantages, including a well-established IDE (Integrated Development Environment) called Microsoft Visual Studio, and advanced security and performance frameworks that handle many of the mundane tasks automatically on the server side, freeing the developer to create more full-fledged web applications and websites.

ASP.NET 4 is the latest iteration in the .NET framework, introducing many new features that build upon its predecessor to improve performance, security, and interoperability with the  latest browsers. Best of all, it comes available with new development tools, including Visual Web Developer 2010 Express Edition and SQL Server 2008 R2 Express Edition, both of which are free! These tools enable the rapid application development (RAD) of web applications.

The goal of this book is to enable you to use all these technologies together in order to produce fantastic results.We’ll take you step by step through each task, showing you how to get the most out of each technology and tool. Let’s begin!

What is ASP.NET?

ASP.NET is a sophisticated and powerful web development framework. If you’ve never used ASP.NET before, it’s likely to take you some time and patience to grow accustomed to it. Development with ASP.NET requires not only an understanding of HTML and web design, but a firm grasp of the concepts of object oriented programming and development. Fortunately, we believe you’ll find the benefits amply reward the learning effort!

In the next few sections, we’ll introduce you to the basics of ASP.NET. We’ll walk through the process of installing it on your web server, and look at a simple example that demonstrates how ASP.NET pages are constructed. But first, let’s define what ASP.NET actually is.

ASP.NET is a server-side technology for developing web applications based on the Microsoft .NET Framework.

Okay, let’s break that jargon-filled sentence down.

ASP.NET is a server-side technology. That is, it runs on the web server. Most web designers cut their teeth learning client-side technologies such as HTML, JavaScript, and Cascading Style Sheets (CSS). When a web browser requests a web page created with only client-side technologies, the web server simply grabs the files that the browser (or client) requests and sends them down the line. The client is entirely responsible for reading the markup in those files and interpreting that markup to display the page on the screen.

Server-side technologies such as ASP.NET, however, are a different story. Instead of being interpreted by the client, server-side code (for example, the code in an ASP.NET page) is interpreted by the web server. In the case of ASP.NET, the code in the page is read by the server and used to generate the HTML, JavaScript, and CSS, which is then sent to the browser. Since the processing of the ASP.NET code occurs on the server, it’s called a server-side technology. As Figure 1.1 shows, the client only sees the HTML, JavaScript, and CSS. The server is entirely responsible for processing the server-side code.


Figure 1.1. A user interacting with a web application

User The transaction starts and ends with the user. The user operates the web client software and interprets the results.
Web client This is the software program that the person uses to interact with the web application. The client is usually a web browser, such as Internet Explorer or Firefox.
Web server This is the software program located on the server. It processes requests made by the web client.

ASP.NET is a technology for developing web applications. A web application is just a fancy name for a dynamic website. A “website” can be thought of as a static page, where the content rarely changes or is purely informational only. Your local dentist or high school probably has a “website”. A web application is dynamic in nature, and often considered to be a web version of standard desktop software. Google Mail is an excellent example of a web application. Web applications usually (but not always) store information in a database,  and allow visitors to the site to access and change that information.

Many different programming technologies and supported languages have been developed to create web applications; PHP, JSP, Ruby on Rails, CGI, and ColdFusion are just a few of the more popular ones. However, rather than tying you to a specific technology and language, ASP.NET lets you write web applications in a variety of familiar programming.We will focus only on the two most popular .NET languages, Visual Basic.NET (often referred to simply as VB.NET or VB) and C# (pronounced “See-Sharp”).

ASP.NET uses the Microsoft .NET Framework. The .NET Framework collects all the technologies needed for building Windows desktop applications, web applications, web services, and so on into a single package, and makes them available to many programming languages. To say that ASP.NET uses the .NET Framework is really a huge understatement. ASP.NET is essentially the web version of what the .NET Framework is to theWindows desktop application world. For instance, if your friend wrote a really neat encryption library using .NET for a Windows desktop application, that code could be easily used within an ASP.NET web application with almost little to no changes.

Even with all the jargon explained, you’re probably still wondering what makes ASP.NET so good. The truth is that there are many server-side technologies around, each of which has its own strengths and weaknesses. Yet ASP.NET has a few unique features:

■ ASP.NET lets you write the server-side code using your favorite programming language—or at least the one you prefer from the long list of supported languages. The .NET Framework currently supports over 40 languages, and many of these may be used to build ASP.NET websites.

■ ASP.NET pages are compiled, not interpreted. In ASP.NET’s predecessor, ASP (“classic ASP”), pages were interpreted: every time a user requested a page, the server would read the page’s code into memory, figure out how to execute the code, and execute it. In ASP.NET, the server need only figure out how to execute the code once. The code is compiled into efficient binary files, which can be run very quickly, again and again, without the overhead involved in rereading the page each time. This allows a big jump in performance, compared to the old days of ASP.

■ ASP.NET has full access to the functionality of the .NET Framework. Support for XML, web services, database interaction, email, regular expressions, and many other technologies are built right into .NET, which saves you from having to reinvent the wheel.

■ ASP.NET allows you to separate the server-side code in your pages from the HTML layout. When you’re working with a team composed of programmers and design specialists, this separation is a great help, as it lets programmers modify the server-side code without stepping on the designers’ carefully crafted HTML—and vice versa.

■ ASP.NET makes it easy to reuse common User Interface elements in many web forms, as it allows us to save those components as independent web user controls. During the course of this book, you’ll learn how to add powerful features to your website, and reuse them in many places with a minimum of effort.

■ You can get excellent tools that assist in developing ASP.NET web applications. Visual Studio 2010 Express is a powerful, free visual editor that includes features such as a visual HTML editor, code autocompletion, code formatting, database integration functionality, debugging, and more. In the course of this book, you’ll learn how to use this tool to build the examples we discuss.

■ Security mechanisms such as membership roles and logins, as well as SQL Injection attack prevention, are automatically enabled out-of-the-box with an ASP.NET web app.

Still with us? Great! It’s time to gather our tools and start building.

Installing the Required Software

If you’re going to learn ASP.NET, you first need to make sure you have all the necessary software components installed and working on your system. Let’s take care of this before we move on.

Visual Web Developer 2010 Express Edition

This is a powerful, free web development environment for ASP.NET 4.0. It includes features such as a powerful code, HTML and CSS editor, project debugging, IntelliSense (Microsoft’s code autocompletion technology), database integration with the ability to design databases and data structures visually, and much more. You’re in for a lot of Visual Web Developer fun during the course of this book.

.NET Framework 4 and the .NET Framework Software Development Kit (SDK)

As we’ve already discussed, the .NET Framework drives ASP.NET. You’re likely to have the .NET Framework already, as it installs automatically through the Windows Update service. Otherwise, it’ll be installed together with Visual Studio.

Microsoft SQL Server 2008 R2 Express Edition

This is the free, but still fully functional, version of SQL Server 2008. This software is a Relational Database Management System whose purpose is to store, manage, and retrieve data as quickly and reliably as possible. You’ll learn how to use SQL Server to store and manipulate the data for the DorkNozzle application you’ll build in this book.

SQL Server Management Studio Express

Because the Express Edition of SQL Server doesn’t ship with any visual management tools, you can use this free tool, also developed by Microsoft, to access your SQL Server 2008 database.

Installing Visual Web Developer 2010 Express Edition

Install VisualWeb Developer 2010 Express Edition by following these simple steps:

1. Browse to and select Microsoft Visual Studio

2. Select the link for Visual Web Developer 2010 Express and click Install Now

3. On the web page; click Install Now

4. .Execute the downloaded file, vwd.exe. This will begin the process for the Web Platform Installer.

5. As part of the installation of Visual Web Developer, you will install SQL Server 2008 R2 Express edition, which is identified as a dependency and automatically installed. The entire download is about 770MB.

fig 1.2

Figure 1.2. Installing Visual Web Developer 2010 Express Edition

6. In the next setup screen, you’ll be asked to select the authentication mode for SQL Server 2008 R2 Express Edition. Here we choose to use Windows Authentication for simplicity going forward. Advanced users may choose to use mixed mode to set up their own account management with SQL Server, however, this book will assume the use of Windows Authentication mode.

7. The installer may prompt you to reboot your computer and possibly download more updates depending on your computer configuration. Please follow the onscreen instructions to ensure you have the latest versions.

8. Start VisualWeb Developer to ensure it has installed correctly for you. Its welcome screen should look like Figure 1.3

fig 1.3

Figure 1.3. The start page of Visual Web Developer 2008 Express Edition

Installing SQL Server Management Studio Express

You’ve just installed Visual Web Developer and SQL Server 2008 R2 Express Editions. You won’t use SQL Server until later in the book when we discuss relational databases, but we’ll install all the required software here so that when the time comes, you’ll have the complete environment set up.

In order to use your SQL Server 2008 instance effectively, you’ll need an administration tool to work with your databases. SQL Server Management Studio Express is a free tool provided by Microsoft that allows you to manage your instance of SQL Server 2008. To install it, follow these steps:

1. Navigate to (or by using your favorite web search engine) and click the Download link under the SQL Server Management Studio Express section.

2. Download the file. After the download completes, execute the file and follow the steps to install the product. Be sure to choose the appropriate edition, whether 32-bit or 64-bit depending on your computer, with database tools. Be sure to choose to do a full install and under Feature Selection you check all boxes.

Once it’s installed, SQL Server Manager Express can be accessed from Start > All Programs > Microsoft SQL Server 2008 > SQL Server Management Studio Express. When executed, it will first ask for your credentials, as Figure 1.4 illustrates.

fig 1.4

Figure 1.4. Connecting to SQL Server

By default, when installed, SQL Server 2008 Express Edition will only accept connections that use Windows Authentication, which means that you’ll use your Windows user account to log into the SQL Server. Since you’re the user that installed SQL Server 2008, you’ll already have full privileges to the SQL Server. Click Connect to connect to your SQL Server 2008 instance.

After you’re authenticated, you’ll be shown the interface in Figure 1.5, which offers you many ways to interact with, and manage, your SQL Server 2008 instance.

SQL Server Management Studio lets you browse through the objects that reside on your SQL Server, and even modify their settings. For example, you can change the security settings of your server by right-clicking COMPUTERSQLEXPRESS (where COMPUTER is the name of your computer), choosing Properties, and selecting Security from the panel, as shown in Figure 1.6.
Here we’ve modified the Server authentication mode to SQL Server and Windows Authentication mode. We’ll need this setting a bit later in the book, but you can set it now if you want, and then click OK.
fig 1.5

Figure 1.5. Managing your database server

fig 1.6

Figure 1.6. Changing server settings with SQL Server Management Studio

That’s it. Your machine is now ready to build ASP.NET web projects and SQL Server databases. Now the fun starts—it’s time to create your very first ASP.NET page!

Like this? Take a look at the book: Build Your Own ASP.NET 4 Website Using C# & VB.

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account