Key Takeaways
- ASP.NET, released in 2002, is a powerful web development framework that enables developers to build robust web applications and websites. It has become popular among corporate and freelance developers due to its advanced security and performance frameworks.
- The latest version, ASP.NET 4, introduces new features that enhance performance, security, and interoperability with the latest browsers. It comes with new development tools, including Visual Web Developer 2010 Express Edition and SQL Server 2008 R2 Express Edition, both of which are free.
- ASP.NET is a server-side technology, meaning it runs on the web server. Unlike client-side technologies like HTML and JavaScript, server-side code is interpreted by the web server. This allows the server to handle many of the processing tasks, freeing up the client to focus on displaying the page.
- ASP.NET lets developers write server-side code using their preferred programming language, with over 40 languages currently supported. ASP.NET pages are compiled, not interpreted, resulting in faster performance. It also has full access to the functionality of the .NET Framework, including support for XML, web services, database interaction, email, and more.
- Visual Studio 2010 Express is a powerful, free visual editor that aids in developing ASP.NET web applications. It includes features such as a visual HTML editor, code autocompletion, code formatting, and database integration functionality. Security mechanisms such as membership roles and logins are automatically enabled with an ASP.NET web app.
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 http://www.microsoft.com/express/ and select Microsoft Visual Studio
2. Select the link for Visual Web Developer 2010 Express and click Install Now
3. On the Microsoft.com 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.
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
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 http://www.microsoft.com/express (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.
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.
Figure 1.5. Managing your database server
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. Need to get right into it? Check out ASP.Net boilerplates.
Frequently Asked Questions (FAQs) about ASP.NET and the .NET Platform
What is the main difference between ASP.NET and .NET platform?
The .NET platform is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large class library known as Framework Class Library (FCL) and provides language interoperability across several programming languages. On the other hand, ASP.NET is a part of the .NET platform that is used for building web applications. It is a server-side web application framework that allows programmers to build dynamic websites, web applications, and web services.
Why should I choose ASP.NET for web development?
ASP.NET offers several advantages for web development. It provides a high level of performance and scalability, thanks to its compiled code and caching functions. It also offers robust security features, including built-in Windows authentication and per-application configuration. Additionally, ASP.NET simplifies the development process with its easy-to-use visual designer and rich toolbox.
Is ASP.NET code considered server-side or client-side?
ASP.NET code is considered server-side. This means that the code is executed on the server before it is sent to the client’s browser. This allows for dynamic content generation based on the server’s data and logic, which can provide a more interactive and personalized user experience.
What are some common client-side web technologies used with ASP.NET?
Some common client-side web technologies used with ASP.NET include HTML, CSS, and JavaScript. These technologies are used to structure content, style the presentation, and add interactivity to web pages, respectively. Additionally, frameworks like Angular, React, and Vue.js can be used with ASP.NET to build more complex and interactive web applications.
Can I use ASP.NET with other programming languages besides C#?
Yes, ASP.NET is language-independent, which means you can use it with several programming languages that are supported by the .NET platform. This includes C#, VB.NET, and F#. This flexibility allows developers to choose the language that best suits their skills and project requirements.
How does ASP.NET handle server-side scripting?
ASP.NET uses server-side scripting to dynamically generate web pages. This is done using a combination of HTML and server-side code. The server-side code is executed on the server, and the resulting HTML is sent to the client’s browser. This allows for dynamic content generation based on the server’s data and logic.
What is the role of the .NET Framework in ASP.NET?
The .NET Framework provides the underlying infrastructure for ASP.NET. It includes a large class library, known as the Framework Class Library (FCL), which provides a wide range of functionalities that ASP.NET applications can use. This includes classes for data access, network communication, file operations, and more.
How secure is ASP.NET for web development?
ASP.NET provides robust security features for web development. It includes built-in Windows authentication and per-application configuration, which can help protect your application from unauthorized access. Additionally, it provides features for data protection, cross-site scripting (XSS) protection, and cross-site request forgery (CSRF) protection.
What is the learning curve for ASP.NET?
The learning curve for ASP.NET can vary depending on your previous programming experience. If you are already familiar with C# or VB.NET, you may find it easier to learn ASP.NET. However, if you are new to programming or coming from a different language, it may take some time to get up to speed.
Can I use ASP.NET for mobile app development?
While ASP.NET is primarily used for web development, it can also be used for mobile app development. This is done using ASP.NET Web API, which allows you to build HTTP services that can be consumed by a wide range of clients, including mobile devices.
Tim Posey is a long-time developer and a passionate educator. Armed with a B.S. in Computer Science and an M.B.A. in Finance, he has traversed many industries, consulting for multiple corporations in banking, insurance, energy, and various e-commerce industries. He serves as a senior software engineer at a Fortune 1000 company and an Adjunct Professor of Finance for the American Public University System. His favorite pastime is watching Alabama football. He may be contacted at tim@timposey.net