Chapter 7: ASP.NET and Web Forms


Overview

Microsoft ASP.NET is a platform for developing Web applications, and it's an ambitious part of the Microsoft .NET Framework. ASP.NET allows you to write XML Web services (as described in Chapter 12) and develop rich Web sites (as discussed in this chapter). ASP.NET Web pages use an event-based control model, which makes writing them remarkably similar to crafting ordinary stand- alone Microsoft Windows “based applications. However, this similarity can be deceiving. As most ASP.NET developers will attest, Web applications have their own idiosyncrasies. For example, you'll need to take extra steps to maintain state, transfer information between pages, handle client-side events, perform authentication, and ensure optimal performance when using a database. This chapter considers all these issues.

Note  

This chapter won't introduce you to ASP.NET if you've never programmed with it before. Instead, it will help intermediate ASP.NET developers solve common problems. For a good introduction to ASP.NET basics, consult one of the many dedicated books and refer to the Microsoft ASP.NET Web site ( http://www.asp.net ).

The recipes you'll find in this chapter cover the following topics:

  • How to redirect user requests (recipe 7.1).

  • Different ways to maintain state between page requests (recipes 7.2 and 7.3).

  • Ways to enhance your interface with client-side features using JavaScript (recipes 7.4, 7.5, and 7.6).

  • Ways to allow users to upload files (recipe 7.7).

  • Two approaches for authenticating the client: integrated Windows authentication with Internet Information Services (IIS) (recipe 7.8) and custom form-based authentication (recipe 7.9).

  • How to validate user input without using ASP.NET validation controls (recipe 7.10).

  • Approaches for dynamically generating Web controls (recipe 7.11), graphics (recipe 7.12), and user controls (recipe 7.13).

  • Techniques for improving performance with output caching (recipe 7.14) and data caching (recipe 7.15).

  • Troubleshooting suggestions to solve the infamous "unable to start debugging on the server" error message (recipe 7.16).

  • How to change the Windows account context in which an ASP.NET application runs (recipe 7.17).

This chapter uses the basic Web classes in the System.Web namespace and the Web control classes in the System.Web.UI.WebControls namespace. When using classes in these core namespaces, the fully qualified class name usually won't be indicated.

Note  

Every recipe in this chapter is contained in a separate virtual directory. To create the required virtual directories, refer to the readme.txt included with the sample code that accompanies the book. Alternatively, you can add the Web page files (both the .asmx pages and the .cs code-behind files) to an existing Web project on your computer to use them.




C# Programmer[ap]s Cookbook
C# Programmer[ap]s Cookbook
ISBN: 735619301
EAN: N/A
Year: 2006
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net