Documente Academic
Documente Profesional
Documente Cultură
NET - CodeProject
1 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
Introduction
I have seen many tutorials on ASP.NET but most of them starts with coding and writing your first ASP.NET Program. But here I
has written this tutorial for explaining why there is a need for ASP.NET when classy ASP is working fine and what are the
underlying technology behind ASP.NET, What programming model ASP.NET Provides to programmers. Now let us get started.
ASP.NET is the new offering for Web developers from the Microsoft .It is not simply the next-generation of ASP; in fact, it is a
completely re-engineered and enhanced technology that offers much, much more than traditional ASP and can increase
productivity significantly.
Because it has evolved from ASP, ASP.NET looks very similar to its predecessorbut only at first sight. Some items look very
familiar, and they remind us of ASP. But concepts like Web Forms, Web Services, or Server Controls gives ASP.NET the power to
build real Web applications.
24/02/2016 16:54
2 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
Introducing ASP.NET
ASP.NET was developed in direct response to the problems that developers had with classic ASP. Since ASP is in such wide use,
however, Microsoft ensured that ASP scripts execute without modification on a machine with the .NET Framework (the ASP
engine, ASP.DLL, is not modified when installing the .NET Framework). Thus, IIS can house both ASP and ASP.NET scripts on the
same machine.
Advantages of ASP.NET
1. Separation of Code from HTML
To make a clean sweep, with ASP.NET you have the ability to completely separate layout and business logic. This makes
it much easier for teams of programmers and designers to collaborate efficiently. This makes it much easier for teams of
programmers and designers to collaborate efficiently.
2. Support for compiled languages
developer can use VB.NET and access features such as strong typing and object-oriented programming. Using compiled
languages also means that ASP.NET pages do not suffer the performance penalties associated with interpreted code.
ASP.NET pages are precompiled to byte-code and Just In Time (JIT) compiled when first requested. Subsequent requests
are directed to the fully compiled code, which is cached until the source changes.
3. Use services provided by the .NET Framework
The .NET Framework provides class libraries that can be used by your application. Some of the key classes help you with
input/output, access to operating system services, data access, or even debugging. We will go into more detail on some
of them in this module.
4. Graphical Development Environment
Visual Studio .NET provides a very rich development environment for Web
developers. You can drag and drop controls and set properties the way you do in Visual Basic 6. And you have full
IntelliSense support, not only for your code, but also for HTML and XML.
5. State management
To refer to the problems mentioned before, ASP.NET provides solutions for session and application state management.
State information can, for example, be kept in memory or stored in a database. It can be shared across Web farms, and
24/02/2016 16:54
3 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
state information can be recovered, even if the server fails or the connection breaks down.
6. Update files while the server is running!
Components of your application can be updated while the server is online and clients are connected. The Framework will
use the new files as soon as they are copied to the application. Removed or old files that are still in use are kept in
memory until the clients have finished.
7. XML-Based Configuration Files
Configuration settings in ASP.NET are stored in XML files that you can easily read and edit. You can also easily copy
these to another server, along with the other files that comprise your application.
ASP.NET Overview
Here are some point that gives the quick overview of ASP.NET.
ASP.NET provides services to allow the creation, deployment, and execution of Web Applications and Web Services
Like ASP, ASP.NET is a server-side technology
Web Applications are built using Web Forms. ASP.NET comes with built-in Web Forms controls, which are responsible for
generating the user interface. They mirror typical HTML widgets like text boxes or buttons. If these controls do not fit
your needs, you are free to create your own user controls.
Web Forms are designed to make building web-based applications as easy as building Visual Basic applications
ASP.NET Architecture
ASP.NET is based on the fundamental architecture of .NET Framework. Visual studio provide a uniform way to combine the
various features of this Architecture.
24/02/2016 16:54
4 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
4. The 4th layer of the framework consists of the Windows application model and, in parallel, the Web application model.
The Web application model-in the slide presented as ASP.NET-includes Web Forms and Web Services.
ASP.NET comes with built-in Web Forms controls, which are responsible for generating the user interface. They mirror
typical HTML widgets like text boxes or buttons. If these controls do not fit your needs, you are free to create your own
user controls.
Web Services brings you a model to bind different applications over the Internet. This model is based on existing
infrastructure and applications and is therefore standard-based, simple, and adaptable.
Web Services are software solutions delivered via Internet to any device. Today, that means Web browsers on computers,
for the most part, but the device-agnostic design of .NET will eliminate this limitation.
5. One of the obvious themes of .NET is unification and interoperability between various programming languages. In order
to achieve this; certain rules must be laid and all the languages must follow these rules. In other words we can not have
languages running around creating their own extensions and their own fancy new data types. CLS is the collection of the
rules and constraints that every language (that seeks to achieve .NET compatibility) must follow.
6. The CLR and the .NET Frameworks in general, however, are designed in such a way that code written in one language can
not only seamlessly be used by another language. Hence ASP.NET can be programmed in any of the .NET compatible
language whether it is VB.NET, C#, Managed C++ or JScript.NET.
Page Syntax
Here is quick introduction of syntax used in ASP.NET
Directives
You can use directives to specify optional settings used by the page compiler when processing ASP.NET files. For each directive
you can set different attributes. One example is the language directive at the beginning of a page defining the default
programming language.
24/02/2016 16:54
5 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
Server-side Comments
24/02/2016 16:54
6 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
To prevent server code from executing, use these character sequences to comment it out. You can comment out full blocks - not
just single lines.
Markup Portion
Web form application part 1 -- SimpleWebForm.aspx
<% @Page Language="C#" Inherits="MoviePage" Src="SimpleWebForm.cs" %>
<html>
<body background="Texture.bmp">
<TITLE>Supermegacineplexadrome!</TITLE>
<H1 align="center"><FONT color="white" size="7">Welcome to
Supermegacineplexadrome!</FONT></H1>
<P align="left"><FONT color="lime" size="5"><STRONG>
<U>Showtimes for <%WriteDate();%></U>
</STRONG></FONT></P>
<FONT size="5" color="yellow"><%WriteMovies();%></FONT>
</body>
</html>
And this is where the C# part of a web forms application comes in.
24/02/2016 16:54
7 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
Execution Cycle :
Now let's see whats happening on the server side. You will shortly understand how server controls fit in.
A request for an .aspx file causes the ASP.NET runtime to parse the file for code that can be compiled. It then generates a page
class that instantiates and populates a tree of server control instances. This page class represents the ASP.NET page.
Now an execution sequence is started in which, for example, the ASP.NET page walks its entire list of controls, asking each one
to render itself.
The controls paint themselves to the page. This means they make themselves visible by generating HTML output to the browser
client.
Execution Process
We need to have a look at whats happening to your code in ASP.NET.
Global.asax
Global.asax is a file used to declare application-level events and objects. Global.asax is the ASP.NET extension of the ASP
Global.asa file. Code to handle application events (such as the start and end of an application) reside in Global.asax. Such event
code cannot reside in the ASP.NET page or web service code itself, since during the start or end of the application, its code has
24/02/2016 16:54
8 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
not yet been loaded (or unloaded). Global.asax is also used to declare data that is available across different application requests
or across different browser sessions. This process is known as application and session state management.
The Global.asax file must reside in the IIS virtual root. Remember that a virtual root can be thought of as the container of a web
application. Events and state specified in the global file are then applied to all resources housed within the web application. If,
for example, Global.asax defines a state application variable, all .aspx files within the virtual root will be able to access the
variable.
Like an ASP.NET page, the Global.asax file is compiled upon the arrival of the first request for any resource in the application.
The similarity continues when changes are made to the Global.asax file; ASP.NET automatically notices the changes, recompiles
the file, and directs all new requests to the newest compilation. A Global.asax file is automatically created when you create a new
web application project in the VS.NET IDE.
Application Directives
Application directives are placed at the top of the Global.asax file and provide information used to compile the global file. Three
application directives are defined, namely Application, Assembly, and Import. Each directive is applied with the following syntax:
<%@ appDirective appAttribute=Value ...%>
Web.config
In ASP, configuration settings for an application (such as session state) are stored in the IIS metabase. There are two major
disadvantages with this scheme. First, settings are not stored in a human-readable manner but in a proprietary, binary format.
Second, the settings are not easily ported from one host machine to another.(It is difficult to transfer information from an IISs
metabase or Windows Registry to another machine, even if it has the same version of Windows.)
Web.config solves both of the aforementioned issues by storing configuration information as XML. Unlike Registry or metabase
entries, XML documents are human-readable and can be modified with any text editor. Second, XML files are far more portable,
involving a simple file transfer to switch machines.
Unlike Global.asax, Web.config can reside in any directory, which may or may not be a virtual root. The Web.config settings are
then applied to all resources accessed within that directory, as well as its subdirectories. One consequence is that an IIS instance
may have many web.config files. Attributes are applied in a hierarchical fashion. In other words, the web.config file at the lowest
level directory is used.
Since Web.config is based on XML, it is extensible and flexible for a wide variety of applications. It is important, however, to note
that the Web.config file is optional. A default Web.config file, used by all ASP.NET application resources, can be found on the
local machine at:
\%winroot%\Microsoft.Net\Framework\version\CONFIG\machine.config
Summary
ASP.NET is an evolution of Microsofts Active Server Page (ASP) technology. Using ASP.NET, you can rapidly develop highly
advanced web applications based on the .NET framework. Visual Studio Web Form Designer, which allows the design of web
applications in an intuitive, graphical method similar to Visual Basic 6. ASP.NET ships with web controls wrapping each of the
standard HTML controls, in addition to several controls specific to .NET. One such example is validation controls, which
intuitively validate user input without the need for extensive client-side script.
In many respects, ASP.NET provides major improvements over ASP, and can definitely be considered a viable alternative for
rapidly developing web-based applications.
Points of Interest
I has write this tutorial to share my Knowledge of ASP.NET with you. You can find more articles and software projects with free
source code on my web site http://programmerworld.net .
24/02/2016 16:54
9 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
History
Date Posted: June 27, 2003
License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves.
If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Share
About the Author
sudhirmangla
Web Developer
India
I am a B.E in Information Technology form Lingaya's Institute of Managemant and Technology Faridabad, India.
I has worked on VC++, MFC, VB, Sql Server. Currently I am working on .net, C# and ASP.net
I keeps my free source code projects and articles at website http://programmerworld.net
24/02/2016 16:54
10 of 10
http://www.codeproject.com/Articles/4468/Beginners-Introduction-to...
Selecione o idioma
24/02/2016 16:54