Asp.Net Introduction


ASP.NET works with Internet Information Server (IIS) to deliver content in response to HTTP requests. ASP.NET pages are found in .aspx files. Figure 26-1 illustrates the technology's basic architecture.

image from book
Figure 26-1

During ASP.NET processing you have access to all .NET classes, custom components created in C# or other languages, databases, and so on. In fact, you have as much power as you would have running a C# application; using C# in ASP.NET is in effect running a C# application.

An ASP.NET file can contain any of the following:

  • Processing instructions for the server

  • Code in C#, Visual Basic .NET, JScript .NET, or any other language that the .NET Framework supports

  • Content in whatever form is appropriate for the generated resource, such as HTML

  • Client-side script code

  • Embedded ASP.NET server controls

So, in fact you could have an ASP.NET file as simple as this:

 Hello! 

This would simply result in an HTML page being returned (as HTML is the default output of ASP.NET pages) containing just this text.

As you see later in this chapter, it is also possible to split certain portions of the code into other files, which can provide a more logical structure.

State Management in ASP.NET

One of the key properties of ASP.NET pages is that they are effectively stateless. By default, no information is stored on the server between user requests (although there are methods for doing this, as you see later in this chapter). At first glance this seems a little strange, because state management is something that seems essential for user-friendly interactive sessions. However, ASP.NET provides a workaround to this problem, such that session management becomes almost transparent.

In short, information such as the state of controls on a Web Form (including data entered in text boxes or selections from drop-down lists) is stored in a hidden viewstate field that is part of the page generated by the server and passed to the user. Subsequent actions, such as triggering events that require server-side processing like submitting form data, result in this information being sent back to the server, known as postback. On the server this information is used to repopulate the page object model allowing you to operate on it as if the changes had been made locally.

You'll see this in action shortly and examine the details.




Professional C# 2005
Pro Visual C++ 2005 for C# Developers
ISBN: 1590596080
EAN: 2147483647
Year: 2005
Pages: 351
Authors: Dean C. Wills

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