Skip to main content
main-content

Über dieses Buch

ASP.NET 4 is the principal standard for creating dynamic web pages on the Windows platform. Pro ASP.NET 4 in C# 2010 raises the bar for high-quality, practical advice on learning and deploying Microsoft's dynamic web solution.

This edition is updated with everything you need to master up to version 4 of ASP.NET, including coverage of ASP.NET MVC, ASP.NET AJAX 4, ASP.NET Dynamic Data, and Silverlight 3.

Seasoned .NET professionals Matthew MacDonald and Mario Szpuszta explain how you can get the most from these groundbreaking technologies. They cover ASP.NET 4 as a whole, illustrating both the newer features and the functionality carried over from previous versions of ASP. This book will give you the knowledge you need to code real ASP.NET 4 applications in the best possible style.

Inhaltsverzeichnis

Frontmatter

Core Concepts

Frontmatter

Chapter 1. Introducing ASP.NET

When the first version of the .NET Framework was released nearly a decade ago, it was the start of a radical new direction in software design. Inspired by the best of Java, COM, and the Web, and informed by the mistakes and limitations of previous technologies, Microsoft set out to “hit the reset button” on their development platform. The result was a set of surprisingly mature technologies that developers could use to do everything from building a Windows application to executing a database query, and a web-site-building tool known as ASP.NET.

Chapter 2. Visual Studio

With ASP.NET, you have several choices for developing web applications. If you’re inclined (and don’t mind the work), you can code every web page and class by hand using a bare-bones text editor. This approach is appealingly straightforward but tedious and error-prone for anything other than a simple page. Professional ASP.NET developers rarely go this route.

Chapter 3. Web Forms

ASP.NET pages (officially known as

web forms

) are a vital part of an ASP.NET application. They provide the actual output of a web application—the web pages that clients request and view in their browsers.

Chapter 4. Server Controls

ASP.NET

server controls

are a fundamental part of the ASP.NET architecture. Essentially, server controls are classes in the .NET Framework that represent visual elements on a web form. Some of these classes are relatively straightforward and map closely to a specific HTML tag. Other controls are much more ambitious abstractions that render a more complex representation from multiple HTML elements.

Chapter 5. ASP.NET Applications

In traditional desktop programming, an

application

is an executable file with related support files. For xample, a typical Windows application consists of a main executable file (EXE), supporting components typically DLLs), and other resources such as databases and configuration files. An ASP.NET application ollows a much different model.

Chapter 6. State Management

No web application framework, no matter how advanced, can change the fact that HTTP is a stateless protocol. After every web request, the client disconnects from the server, and the ASP.NET engine discards the objects that were created for the page. This architecture ensures that web applications can scale up to serve thousands of simultaneous requests without running out of server memory. The drawback is that your code needs to use other techniques to store information between web requests and retrieve it when needed.

Data Access

Frontmatter

Chapter 7. ADO.NET Fundamentals

The .NET Framework includes its own data access technology: ADO.NET. ADO.NET consists of managed classes that allow .NET applications to connect to data sources (usually relational databases), execute commands, and manage disconnected data. The small miracle of ADO.NET is that it allows you to write more or less the same data access code in web applications that you write for client-server desktop applications, or even single-user applications that connect to a local database.

Chapter 8. Data Components and the DataSet

In the previous chapter, you had your first look at ADO.NET, and you examined connection-based data access. Now, it’s time to bring your data access code into a well-designed application.

Chapter 9. Data Binding

Almost every web application has to deal with data, whether it’s stored in a database, an XML file, a structured file, or something else. Retrieving this data is only part of the challenge—a modern application also needs a convenient, flexible, and attractive way to display the data in a web page.

Chapter 10. Rich Data Controls

In the previous chapter, you saw how to use the data source controls to perform queries, both with and without the assistance of a custom data access class. Along the way, you used some of ASP.NET’s rich data controls, such as the GridView. However, you haven’t delved into all the features these controls provide.

Chapter 11. Caching and Asynchronous Pages

Caching

is the technique of storing an in-memory copy of some information that’s expensive to create. For example, you could cache the results of a complex query so that subsequent requests don’t need to access the database at all. Instead, they can grab the appropriate object directly from server memory—a much faster proposition. The real beauty of caching is that unlike many other performance-enhancing techniques, caching bolsters both performance and scalability. Performance is better because the time taken to retrieve the information is cut down dramatically. Scalability is improved because you work around bottlenecks such as database connections. As a result, the application can serve more simultaneous page requests with fewer database operations.

Chapter 12. Files and Streams

Most web applications rely heavily on databases to store information. Databases are unmatched in multiuser scenarios. They handle simultaneous access without a hitch, and they support caching and low-level disk optimizations that guarantee blistering performance. Quite simply, an RDBMS (Relational Database Management System) offers the most robust and best-performing storage for data.

Chapter 13. LINQ

One of the most hyped additions to.NET is LINQ (Language Integrated Query), a set of language extensions that allows you to perform

queries

without leaving the comfort of the C# language.

Chapter 14. XML

Ever since XML (Extensible Markup Language) first arrived on the scene in the late 1990s, it has been the focus of intense activity and overenthusiastic speculation. Based on nothing but ordinary text, XML offers a means of sharing data between just about any two applications, whether they’re new or old, written in different languages, built by distinct companies, or even hosted on different operating systems. Now that XML has come of age, it’s being steadily integrated into different applications, problem domains, and industries.

Building ASP.NET Websites

Frontmatter

Chapter 15. User Controls

The core set of ASP.NET controls is broad and impressive. It includes controls that encapsulate basic HTML tags and controls that provide a rich higher-level model, such as the Calendar, TreeView, and data controls. Of course, even the best set of controls can’t meet the needs of every developer. Sooner or later, you’ll want to get under the hood, start tinkering, and build your own user interface components.

Chapter 16. Themes and Master Pages

Building a professional web application involves much more than designing individual web pages. You also need the tools to integrate your web pages into a complete, unified website. In this chapter, you’ll consider two ASP.NET features that let you do that.

Chapter 17. Website Navigation

Navigation is a fundamental component of any website. Although it’s easy enough to transfer the user from one page to another, creating a unified system of navigation that works across an entire website takes more effort. While you could build your own navigation system with a few links (and a lot of work), ASP.NET has a built-in navigation system that makes it easy.

Chapter 18. Website Deployment

In production projects, you will almost certainly have one of more servers that you will use to service client requests for your website. These servers may be owned and operated by you or your infrastructure team or by a third-party hosting company. Either way, there comes a time when the coding and testing is complete and it is time to publish your work to the world, and you do that by

deploying

your website. In this chapter, we’ll walk you through the different deployment options. The basic premise for all the options is the same, though. You have a completed website on your development workstation that you want to deploy to a server in order that it is available to clients. For ASP.NET, the server in this scenario is Internet Information Services (IIS), and the current version is IIS 7. IIS started out as a basic web server when it was first released. Over the years, IIS has evolved into a sophisticated application server with a wide range of features, key among them being support for hosting ASP.NET applications.

Security

Frontmatter

Chapter 19. The ASP.NET Security Model

Security is an essential part of web applications and should be taken into consideration from the first stage of the development process. Essentially, security is all about protecting your assets from unauthorized actions. You use several mechanisms to this end, including identifying users, granting or denying access to sensitive resources, and protecting the data that’s stored on the server and transmitted over the wire. In all of these cases, you need an underlying framework that provides basic security functionality. ASP.NET fills this need with built-in functionality that you can use for implementing security in your web applications.

Chapter 20. Forms Authentication

In the previous chapter, you learned about the basic structure of ASP.NET security. In this chapter, you will learn how you can authenticate your users using

forms authentication

. You should use this type of authentication whenever there is a reason for not using Windows-based accounts in your applications. We will discuss such reasons in this chapter, as well as in Chapter 22 when discussing Windows authentication itself.

Chapter 21. Membership

On one hand, forms authentication solves the critical fundamentals for implementing secure, custom login forms for your ASP.NET applications. On the other hand, the tasks you have to accomplish for implementing the login forms and communicating with the underlying credential store are almost always the same for every web application, and they’re tedious. You should keep in mind one more point: forms authentication provides the infrastructure for authenticating users only. If you are using a custom credentials store, you have to write administration applications for managing users, which need to implement functionality for adding users, removing users, resetting passwords, and much more. Implementing such functionality is fairly similar for every web application and gets boring quickly.

Chapter 22. Windows Authentication

Forms authentication is a great approach if you want to roll your own authentication system using a back-end database and a custom login page. But what if you are creating a web application for a smaller set of known users who already have Windows user accounts? In these situations, it makes sense to use an authentication system that can leverage the existing user and group membership information.

Chapter 23. Authorization and Roles

So far, you’ve seen how to confirm that users are who they say they are and how to retrieve information about those authenticated identities. This gives your application the basic ability to distinguish between different users, but it’s only a starting point. To create a truly secure web application, you need to act upon that identity at various points using

authorization

.

Chapter 24. Profiles

In previous chapters, you learned how to use a range of ASP.NET security features. Many of these features are geared to identifying individual users (authentication) and then determining what actions they should be able to perform (authorization). But you need to uniquely identify and authenticate users for another important reason—to keep track of user-specific information.

Chapter 25. Cryptography

In Chapters 19–23, you learned how to identify users through several supported authentication mechanisms and how to implement authorization for those users in your applications. ASP.NET supports rich services, such as the membership and roles APIs, that help you implement this functionality. However, although authentication and authorization are two important factors for securing applications, you have to keep much more in mind. Therefore, .NET has a bit more functionality in store. One of the most important examples is .NET’s support for

cryptography

—the science of scrambling data to ensure confidentiality and adding hash codes to detect tampering.

Chapter 26. Custom Membership Providers

In the previous chapters, you learned all the necessary details for authenticating and authorizing users with ASP.NET through both forms authentication and Windows authentication. You learned that with forms authentication on its own, you are responsible for managing users (and roles if you want to implement role-based authorization in your application) in a custom store.

Advanced User Interface

Frontmatter

Chapter 27. Custom Server Controls

Each type of custom control has its own advantages and disadvantages. In Chapter 15, you learned about user controls. User controls are easier to create than custom server controls, but server controls are far more powerful. Server controls beat user controls in two key areas:

Server controls give you complete control over the HTML you generate

: In other words, you can create a control such as the ASP.NET Calendar, which provides a single object interface but renders itself as a complex combination of elements.

Server controls provide better design-time support

: You can add them to the Toolbox in Visual Studio and set properties and add event handlers at design time. You can even configure the description that Visual Studio will show for each property, along with other design-time niceties.

Chapter 28. Graphics, GDI+, and Charting

In Chapter 4, you learned about basic web controls for displaying graphics, such as the Image and ImageButton controls. Both allow you to display an image, and the ImageButton control also fires a Click event that gives you the exact mouse coordinates. But in a modern web application, you’ll often want much more.

Chapter 29. JavaScript and Ajax Techniques

ASP.NET provides a rich server-based programming model. The postback architecture allows you to perform all your work with object-oriented programming languages on the server, which ensures that your code is secure and compatible with all browsers. However, the postback architecture has its weaknesses. Because posting back the page always involves some small but noticeable overhead, it’s impossible to react efficiently to mouse movements and key presses. Additionally, certain tasks—such as showing pop-up windows, providing a real-time status messages, and communicating between frames—need browser interaction and just aren’t possible with server-side programming.

Chapter 30. ASP.NET AJAX

In the previous chapter, you entered the world of client-side programming. You learned a few essential techniques for using JavaScript, and you considered how to create more responsive pages with Ajax techniques, either on your own or through the client callback feature in ASP.NET.

Chapter 31. Portals with Web Part Pages

Websites are more sophisticated than ever. Nowadays it’s not enough if a website has a great look and feel. It has to be easy to use and must present exactly the information that users want to see. In addition, users want websites to present this information in a specific way—based on their individual preferences. Therefore, personalization and user profiles have become more important in web development.

Chapter 32. MVC

Microsoft has introduced MVC as an alternative to web forms (covered in Chapter 3). MVC is based on ASP.NET, so all the skills you have learned in previous chapters can be applied to an MVC application. MVC is a framework that lets you leverage your ASP.NET knowledge to build applications quickly— much like web forms and much like the dynamic data framework covered in Chapter 33.

Chapter 33. Dynamic Data

ASP.NET Dynamic Data allows you to build data-centric web applications quickly and with very little effort. Template pages are populated by inferring type information from a data model schema, and little or no coding is required. The amount of functionality you can get with 15 minutes of work can be pretty impressive, and once the basic features have been created for you, there are extensive options for customization.

Chapter 34. Silverlight

Although the Web is easily the most popular environment for business software, there are some things that web applications just can’t do, or can’t do very well. Even if you outfit your ASP.NET web pages with the latest cutting-edge JavaScript and Ajax you won’t be able to duplicate many of the capabilities that desktop applications take for granted, such as animation, sound and video playback, and 3D graphics. And although you can use JavaScript to respond on the client to focus changes, mouse movements, and other “real-time” events, you still can’t build a complex interface that’s anywhere near as responsive as a window in a rich client application. (The saving grace of web programming is that you usually don’t need these frills. The benefits you gain—broad compatibility, high security, no deployment cost, and a scalable server-side model—outweigh the loss of a few niceties.)

Backmatter

Weitere Informationen

Premium Partner

Neuer Inhalt

BranchenIndex Online

Die B2B-Firmensuche für Industrie und Wirtschaft: Kostenfrei in Firmenprofilen nach Lieferanten, Herstellern, Dienstleistern und Händlern recherchieren.

Whitepaper

- ANZEIGE -

Best Practices für die Mitarbeiter-Partizipation in der Produktentwicklung

Unternehmen haben das Innovationspotenzial der eigenen Mitarbeiter auch außerhalb der F&E-Abteilung erkannt. Viele Initiativen zur Partizipation scheitern in der Praxis jedoch häufig. Lesen Sie hier  - basierend auf einer qualitativ-explorativen Expertenstudie - mehr über die wesentlichen Problemfelder der mitarbeiterzentrierten Produktentwicklung und profitieren Sie von konkreten Handlungsempfehlungen aus der Praxis.
Jetzt gratis downloaden!

Bildnachweise