Saturday, March 5, 2011

What is ASP.Net ?

What is ASP.NET?

ASP.NET is a server side scripting technology given by Microsoft that enables scripts (embedded in web pages) to be executed by an Internet server.

  • ASP.NET is a Microsoft Technology
  • ASP stands for Active Server Pages
  • ASP.NET is a program that runs inside IIS
  • IIS (Internet Information Services) is Microsoft's Internet server
  • IIS comes as a free component with Windows servers
  • IIS is also a part of Windows 2000 and XP Professional

Types of Application in ASP.net with C#:
1. Console application
2. Web based application
3. Windows based application


Creating . NET Applications Using C#


C# can also be used to create console applications: text - only applications that run in a DOS window. You
will probably use console applications when unit testing class libraries, and for creating UNIX or Linux
daemon processes. More often, however, you will use C# to create applications that use many of the
technologies associated with .NET. This section gives you an overview of the different types of
applications that you can write in C#.
Creating ASP . NET Applications
Active Server Pages (ASP) is a Microsoft technology for creating Web pages with dynamic content. An
ASP page is basically an HTML file with embedded chunks of server - side VBScript or JavaScript. When
a client browser requests an ASP page, the Web server delivers the HTML portions of the page,
processing the server - side scripts as it comes to them. Often these scripts query a database for data and
mark up that data in HTML. ASP is an easy way for clients to build browser - based applications.
However, ASP is not without its shortcomings. First, ASP pages sometimes render slowly because the
server - side code is interpreted instead of compiled. Second, ASP files can be difficult to maintain because
they are unstructured; the server - side ASP code and plain HTML are all jumbled up together. Third, ASP
sometimes makes development difficult because there is little support for error handling and type -
checking. Specifically, if you are using VBScript and want to implement error handling in your pages,
you must use the On Error Resume Next statement, and follow every component call with a check to
Err.Number to make sure that the call has gone well.
ASP.NET is a complete revision of ASP that fixes many of its problems. It does not replace ASP;
rather, ASP.NET pages can live side by side on the same server with legacy ASP applications. Of course,
you can also program ASP.NET with C#!
The following section explores the key features of ASP.NET. For more details, refer to Chapters 37 , “ ASP.
NET Pages, ” 38 , “ ASP.NET Development, ” and 39 , “ ASP.NET AJAX. ”
Features of ASP . NET
First, and perhaps most important, ASP.NET pages are structured . That is, each page is effectively a class
that inherits from the .NET System.Web.UI.Page class and can override a set of methods that are
evoked during the Page object ’ s lifetime. (You can think of these events as page - specific cousins of the
OnApplication_Start and OnSession_Start events that went in the global.asa files of plain old
ASP.) Because you can factor a page ’ s functionality into event handlers with explicit meanings, ASP.NET
pages are easier to understand.
Another nice thing about ASP.NET pages is that you can create them in Visual Studio 2008, the same
environment in which you create the business logic and data access components that those ASP.NET
pages use. A Visual Studio 2008 project, or solution , contains all of the files associated with an application.
Moreover, you can debug your classic ASP pages in the editor as well; in the old days of Visual InterDev,
it was often a vexing challenge to configure InterDev and the project ’ s Web server to turn debugging on.
For maximum clarity, the ASP.NET code - behind feature lets you take the structured approach even
further. ASP.NET allows you to isolate the server - side functionality of a page to a class, compile that class
into a DLL, and place that DLL into a directory below the HTML portion. A code - behind directive at
the top of the page associates the file with its DLL. When a browser requests the page, the Web server
fires the events in the class in the page ’ s code - behind DLL.

interpreted with each page request, the Web server caches ASP.NET pages after compilation. This means
that subsequent requests of an ASP.NET page execute more quickly than the first.
ASP.NET also makes it easy to write pages that cause forms to be displayed by the browser, which you
might use in an intranet environment. The traditional wisdom is that form - based applications offer a
richer user interface but are harder to maintain because they run on so many different machines. For this
reason, people have relied on form - based applications when rich user interfaces were a necessity and
extensive support could be provided to the users.
Web Forms
To make Web page construction even easier, Visual Studio 2008 supplies Web Forms . They allow you to
build ASP.NET pages graphically in the same way that Visual Basic 6 or C++ Builder windows are
created; in other words, by dragging controls from a toolbox onto a form, then flipping over to the code
aspect of that form and writing event handlers for the controls. When you use C# to create a Web Form,
you are creating a C# class that inherits from the Page base class and an ASP.NET page that designates
that class as its code behind. Of course, you do not have to use C# to create a Web Form; you can use
Visual Basic 2008 or another .NET - compliant language just as well.
In the past, the difficulty of Web development discouraged some teams from attempting it. To succeed in
Web development, you needed to know so many different technologies, such as VBScript, ASP, DHTML,
JavaScript, and so on. By applying the Form concepts to Web pages, Web Forms have made Web
development considerably easier.
Web Server Controls
The controls used to populate a Web Form are not controls in the same sense as ActiveX controls. Rather,
they are XML tags in the ASP.NET namespace that the Web browser dynamically transforms into HTML
and client - side script when a page is requested. Amazingly, the Web server is able to render the same
server - side control in different ways, producing a transformation appropriate to the requestor ’s particular Web browser। This means that it is now easy to write fairly sophisticated user interfaces for Web pages, without worrying about how to ensure that your page will run on any of the अवैलब्ले browsers — because Web Forms will take care of that for you।
You can use C# or Visual Basic 2008 to expand the Web Form toolbox. Creating a new server - side control
is simply a matter of implementing .NET ’ s System.Web.UI.WebControls.WebControl class.
XML Web Services
Today, HTML pages account for most of the traffic on the World Wide Web. With XML, however,
computers have a device - independent format to use for communicating with each other on the Web. In
the future, computers may use the Web and XML to communicate information rather than dedicated
lines and proprietary formats such as Electronic Data Interchange (EDI). XML Web services are designed
for a service - oriented Web, in which remote computers provide each other with dynamic information
that can be analyzed and reformatted, before final presentation to a user. An XML Web service is an easy
way for a computer to expose information to other computers on the Web in the form of XML.
In technical terms, an XML Web service on .NET is an ASP.NET page that returns XML instead of HTML
to requesting clients. Such pages have a code - behind DLL containing a class that derives from the
WebService class. The Visual Studio 2008 IDE provides an engine that facilitates Web service
development.
An organization might choose to use XML Web services for two main reasons. The first reason is that
they rely on HTTP; XML Web services can use existing networks (HTTP) as a medium for conveying
information. The other is that because XML Web services use XML, the data format is self - describing,
nonproprietary, and platform - independent.

Creating Windows Forms
Although C# and .NET are particularly suited to Web development, they still offer splendid support for
so - called fat - client or thick - client apps — applications that must be installed on the end user ’ s machine
where most of the processing takes place. This support is from Windows Forms .
A Windows Form is the .NET answer to a Visual Basic 6 Form. To design a graphical window interface,
you just drag controls from a toolbox onto a Windows Form. To determine the window ’ s behavior, you
write event - handling routines for the form ’ s controls. A Windows Form project compiles to an executable
that must be installed alongside the .NET runtime on the end user ’ s computer. Like other .NET project
types, Windows Form projects are supported by both Visual Basic 2008 and C#. Chapter 31 , “ Windows
Forms, ” examines Windows Forms more closely.
Using the Windows Presentation Foundation ( WPF )
One of the newest technologies to hit the block is the Windows Presentation Foundation (WPF). WPF
makes use of XAML in building applications. XAML stands for Extensible Application Markup
Language. This new way of creating applications within a Microsoft environment is something that was
introduced in 2006 and is part of the .NET Framework 3.0 and 3.5. This means that to run any WPF
application, you need to make sure that the .NET Framework 3.0 or 3.5 is installed on the client machine.
WPF applications are available for Windows Vista, Windows XP, Windows Server 2003, and Windows
Server 2008 (the only operating systems that allow for the installation of the .NET Framework 3.0 or 3.5).
XAML is the XML declaration that is used to create a form that represents all the visual aspects and
behaviors of the WPF application. Though it is possible to work with a WPF application
programmatically, WPF is a step in the direction of declarative programming, which the industry is
moving to. Declarative programming means that instead of creating objects through programming in a
compiled language such as C#, VB, or Java, you declare everything through XML - type programming.
Chapter 34 , “ Windows Presentation Foundation ” details how to build these new types of applications
using XAML and C#.

Your First C# Program
Let ’ s start by compiling and running the simplest possible C# program — a simple class consisting of a
console application that writes a message to the screen.
Later chapters present a number of code samples. The most common technique for writing C# programs
is to use Visual Studio 2008 to generate a basic project and add your own code to it. However, because
the aim of these early chapters is to teach the C# language, we are going to keep things simple and avoid
relying on Visual Studio 2008 until Chapter 15 , “ Visual Studio 2008. ” Instead, we will present the code
as simple files that you can type in using any text editor and compile from the command line.
The Code
Type the following into a text editor (such as Notepad), and save it with a .cs extension (for example,
First.cs ). The Main() method is shown here:
using System;
namespace Wrox.ProCSharp.Basics
{
class MyFirstCSharpClass
{
static void Main()
{
Console.WriteLine(“This isn’t at all like Java!”);
Console.ReadLine();
return;
}
}
}
Compiling and Running the Program
You can compile this program by simply running the C# command - line compiler ( csc.exe ) against the
source file, like this:
csc First.cs
If you want to compile code from the command line using the csc command, you should be aware that
the .NET command - line tools, including csc , are available only if certain environment variables have
been set up. Depending on how you installed .NET (and Visual Studio 2008), this may or may not be the
case on your machine.

Compiling the code produces an executable file named First.exe , which you can run from the
command line or from Windows Explorer like any other executable. Give it a try:
csc First.cs
Microsoft (R) Visual C# Compiler version 9.00.20404
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
First.exe
This isn’t at all like Java!
Well, maybe that message isn ’ t quite true! This program has some fairly fundamental similarities to Java,
although there are one or two points (such as the capitalized Main() function) to catch the unwary
Java or C++ developer. Let ’ s look more closely at what ’ s going on in the code.

For more please visit : sharepointcafe.net

No comments:

Post a Comment