Você está na página 1de 12

Unit-1 Introduction to ASP.

NET web
programming & IDE

BASIC OF ASP.NET
• Asp.net refers as Active Server Pages .net which is server side object oriented programming language.
• Asp.net is language of Microsoft.net framework to develop web applications.
• Benefits:-
o Easier OOP Language
o Quick Drag & Drop Control
o Code Separation
o Easier database operations
o Version Compatibility
o High Security
o Easy application Development
o Highly Integrated IDE
• Asp.net uses to develop dynamic web pages, web services and web application.
• Asp.net is built on the CLR(Common Language Runtime) that allows user to write Asp.net program
using any .net framework supported language like C#, VB, Visual C++, J# etc..
• Asp.net also supports ADO.NET (ActiveX data object.Net) that helps to connect and work with data
stored in database.
• Asp.net also provide everything Readymade such as Rich controls, Validation controls, Databound
controls, Ajax controls for developing easier, fast and highly dynamic web applications.

FEATURES OF ASP.NET *
• Simplified Programming Model: ASP.NET is a technology which can be implemented using any dotnet
language such as C#.Net or VB. Net
• Side by side Execution: Side by side execution is the ability to run multiple version of an application or
component on the same computer
• Server side Controls: ASP.NET technology has introduced rich powerful web server controls which are
capable to identify the clients’ browser and can render the HTML tags accordingly.
• Performance: Architecture of the ASP.NET is designed in order to increase the performance of the
application.
• Powerful Database Support: ASP.NET supports very large amount of database class and it also provide
the easy deployment of the connectivity with the application.
• Web Services: With the help of ASP.NET we can also develop the web services, which are useful for the
communication of protocols, it can be also used by other application, it is an application components.
• Simplified Form Validation: In other language we have to write so may line of codes to validate a
control, while in ASP.NET it becomes Easy and Simple for Deployment.
• Simplified Deployment: With the help of the CLR, We can develop our applications in any language so
we don’t have to worry about programming language. Visual Studio provides all the functionality of
drag of controls, we deployment becomes fast and easy. We can easily configure IIS (Internet Information
Service).
• Rich Tool Box Support: ASP.NET supports a very high range of tools which can be easily implemented.
1 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura
Unit-1 Introduction to ASP.NET web
programming & IDE

DIFFERENCES BETWEEN ASP.NET AND CLASSIC ASP


ASP.NET Classic ASP
ASP.NET is full featured object oriented programming. It has limited oops support and not having built in
It has full support of xml. This helps easy data support for xml.
exchange.
Various tools and compiler available. Microsoft Visual Very less development and debugging tool available.
studio makes your debugging job easier. Meaning that difficult to debug the code.
ASP.NET we can use either C# or VB.NET as server ASP you can only do scripting using visual basic
side programming language. scripting and java scripting.
Error handling is very good. Error handling is very poor.
ASP.NET gives you three tire architecture. It allows It has no high level programming structure. Mixed of
you to keep your business logic, views everything html and server side scripting.
separate.
In built validation controls. It has rich validation set - It has no in built validation control. Meaning that
custom validator, range validator, regular expression, validating page is difficult for developers.
compare and require field validation control which
makes your job easier.
It has state management support. In the classic ASP if you need to update code on the
existing page then it is mandatory to restart the
server to get reflect.
OOP Language Support. Scripting Language Support.
Inheritance Supports. Doesn't Support Inheritance.
Separate file for code and data both. Single file for code and data.
Supports Custom Controls. Doesn't Support Custom Controls.
ADO.Net with XML integration. Simple ADO with limited functionalities.

WEB APPLICATIONS AND WEBPAGE


Web-Page/Web-Site Web-Application
A website is informational. OR website is defined by A web application is interactive. OR web application is
its content. defined by its interaction with the user.
Website we can create pages in multi programming Web application we have chance of select only one
languages that mean we can create one page code in programming language during creation of project
C# and another page code in vb.net. either C# or VB.NET.
Web Sites won’t create any .csproj/.vbproj files in When we create Web Application those will
project. automatically create project files (.csproj or .vbproj).
No need to recompile the site before deployment. We need to pre-compile the site before deployment.
Example:- www.darshan.ac.in Example:- Google doc

2 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE

Common Language Runtime (CLR):


• The heart of the .Net framework is the Common Language Runtime (CLR).
• CLR manages the execution of the whole application.
• In the CLR, code is expressed as the byte code called the MSIL code (MSIL = Microsoft Intermediate
Language).
• Developers using the CLR, write code in a language such as C# or VB.NET. At Compile time, a .NET Compiler
converts such code into MSIL code.
• During run time, the CLR converts the MSIL code into something that can be understood by the operating system.
• At runtime, MSIL’s just-in-time compiler converts the MSIL code to the Native code.
• JIT compiler converts the MSIL code in to the Native Code, which is related to the particular systems.
• Rather than converts all the code to the native code JIT compiler will converts the required amount of
code to the Native code and saves the time and memory both.
• The CLR manages memory, thread execution, garbage collection, exception handling, common type
system, code safety verifications and other system services.

C# Code VB.NET J# Code

Compiler Compiler Compiler

JIT
Microsoft Intermediate
Compile
Language(MSIL)
r

CLR

101011100011010

Common Type System (CTS):


• As .Net framework is language independent and support over 20 different programming languages, many
programming language will write data types in their own programming languages.
• For example, an integer variable in C# is written as Int, where as in visual basic it is written as integer.
• CTS define the basic data types that IL understands. Each .NET compliant language should map its data
types to these standard data types.
• This makes it possible for the 2 languages to communicate with each other by passing/receiving
parameters to/from each other.

3 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE

COMPONENTS OF WEB APPLICATION


Web Form
• ASP.NET Web Form is a programmable Web page (.aspx file).
• Acts as a user interface (UI) of an ASP.NET application.
• Consists of HTML, code and controls which are executed on a web server.
• The user will see the result in the form of HTML Page, which was generated by the web server.

Web Control
• ASP.NET Web server controls are objects on ASP.NET Web pages that run when the page is requested.
• Many Web server controls are similar to HTML elements, such as buttons and text boxes.
• Other controls have complex behavior, such as a calendar controls, and datacontrols that you can use
to connect to data sources and display data.

Web.Config
• Configuration file is used to manage various settings that define a website. The settings are stored in
XML files that are separate from your application code. Generally a website contains a single
Web.config file stored inside the application root directory.
• There are number of important settings that can be stored in the configuration file. Some of the most
frequently used configurations, stored inside Web.config file are: Database connections, Caching
settings, Session States, Error Handling, Security.
• Configuration file looks like this:
<configuration>
<connectionStrings>
<add name ="myCon" connectionString ="server= ANS-PC\SQLEXPRESS; database=Demo;”/>
</connectionStrings>
</configuration/>

Machine.config
• The machine.config file is the master configuration file on your system with a lot of default settings.
• The settings of Machine.config file are applied to the whole asp.net applications on your server.
• Each .NET Framework version has only one machine.config file.
• The machine.config would be to share values between many applications on the server.

Global.asax
• The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code
for responding to application-level events raised by ASP.NET.
• Only one Global.asax file per application and it should be located in application’s root directory only.
• Application-level events are: Application_Start, Application_End, Session_Start, Session_End.

4 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE

CLIENT SERVER ARCHITECTURE


• Three-tier (layer) is a client-server architecture in which the user interface, business process (business
rules) and data storage and data access are developed and maintained as independent modules or
most often on separate platforms.
• Basically, there are 3 layers, tier 1 (presentation tier, GUI tier), tier 2 (business objects, business logic
tier) and tier 3 (data access tier). These tiers can be developed and tested separately.

5 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE
Presentation Layer
• The Presentation Layer contains pages like .aspx where data is presented to the user or input is taken
from the user. The ASP.NET web site (the UI for the project) is called the Presentation Layer.
• The Presentation Layer is the most important layer simply because it’s the one that everyone sees and
uses. Even with a well structured business and data layer, if the Presentation Layer is designed poorly,
this gives the users a poor view of the system.

Business Layer
• A Business Layer contains business logic, validations or calculations related to the data.
• Though a web site could talk to the data access layer directly, it usually goes through another layer
called the Business Layer. The Business Layer validates the input conditions before calling a method
from the data layer. This ensures the data input is correct before proceeding, and can often ensure
that the outputs are correct as well. This validation of input is called business rules, meaning the rules
that the Business Layer uses to make “judgments” about the data.

Data Layer
• A Data Layer contains methods that help the Business Layer to connect the data and perform required
actions, whether to return data or to manipulate data (insert, update, delete and so on).
DIFFERENCE BETWEEN 2-TIER & 3-TIER ARCHITECTURE:
2-Tier Architecture 3-Tier Architecture
It has 2 layers one is database layer & another is It has 3 layers, one is database layer, second is logic layer
presentation layer and third is presentation layer
Less Secure compare to 3-Tier Architecture Secure compare to 2-Tier Architecture
Performance is poor because here task of logic layer and Performance is good as there are 3 tiers
database layer will be done by only database layer
Only one database can be used Here we can use multiple database also
Less Reusability Better Reusability
Tuff task to maintain Easy to maintain

(https://www.tuturself.com/posts/view?menuId=90&po (https://www.tuturself.com/posts/view?menuId=90&postId
stId=465) =465)

6 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE

CREATING SIMPLE WEB APPLICATION IN ASP.NET


INTRODUCTION TO VISUAL STUDIO
• Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to
develop computer programs for Microsoft Windows, as well as web sites, web applications and web
services.
• Menu Bar:
File Contains commands for opening projects, closing projects, printing project data, etc.
Edit Contains commands such as cut, paste, find, undo, etc.
View Contains commands for displaying IDE windows and toolbars.
Contains commands for debugging (i.e., identifying and correcting problems in a
Debug
program) and running a program.
Contains commands for accessing additional IDE tools and options that enable
Tools
customization of the IDE.
Windows Contains commands for arranging and displaying windows.
Help Contains commands for accessing the IDE’s help features.

• Toolbox: The Toolbox window contains controls used to customize forms. Programmers can “drag and
drop” controls onto the form.
• Properties: The Properties window displays the properties for a form or control. Properties specify
information such as size, color and position.
• Solution Explorer: The solution explorer window provides access to all the files in the solution.

CREATING A NEW WEB PROJECT (ASP.NET)


• Select File->New Project within the Visual Studio 2008 IDE. This will bring up the New Project dialog.
Click on the “Visual Basic” node in the left hand side of the dialog box and choose the "ASP.NET Web
Application" icon:

7 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE
• Choose where you want the project to be created on disk. Then name it and hit ok.
• Visual Studio will then create and open a new web project within the solution explorer. By default it
will have a single page (Default.aspx), web.config file. All project file-meta-data is stored within a
MSBuild based project file.

OPENING AN EXISTING WEB SITES


• To open existing project go to File->Open->Project/Solution. Open the project folder which you want
and then double click on Microsoft Visual Studio Solution(.sln) file.
BUILDING WEB SITES
• Hit F5 to build and run the project in debug mode.
• By default, ASP.NET Web Application projects are configured to use the built-in VS web-server when
run.
• The default project templates will run on a random port as a root site (for example:
http://localhost:49665/Default.aspx)

Set up of work environment, Start page, the menu system, toolbars, the new project dialog
box, graphical designer, code designer
• The new project window allows choosing an application template from the available templates.
• When you start a new web site, ASP.NET provides the starting folders and files for the site, including
two files for the first web form of the site.
• The file named Default.aspx contains the HTML and asp code that defines the form, and the file named
Default.aspx.cs (for C# coding) or the file named Default.aspx.vb (for vb coding) contains the code in
the language you have chosen and this code is responsible for the form's works.
• The primary window in the Visual Studio IDE is the Web Forms Designer window. Other supporting
windows are the Toolbox, the Solution Explorer, and the Properties window.
• You use the designer to design a web form, to add code to the control on the form so that the form
works according to your need, you use the code editor.

8 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE
• To change the Web Forms Designer from one view to another, click on the Design or source button.
• To close a window, click on the close button on the upper right corner and to redisplay, select it from
the View menu.
• To hide a window, click on its Auto Hide button; the window changes into a tab, to redisplay again click
on the Auto Hide button again.
• When a new web form is created, Visual Studio automatically generates the starting HTML for the form
and displays it in Source view of the web forms designer. The Solution Explorer is used to add any other
files, folders or any existing item on the web site.

• To add a standard folder, right-click on the project or folder under which you are going to add the
folder in the Solution Explorer and choose New Folder.
• To add an ASP.Net folder, right-click on the project in the Solution Explorer and select the folder from
the list.
• To add an existing item to the site, right-click on the project or folder under which you are going to add
the item in the Solution Explorer and select from the dialog box.

WORKING WITH ASP.NET WEB FORMS


TYPES OF ASP.NET FILES **
File type Description
.asax The Global.asax file, also known as the ASP.NET application file, is an optional file
that contains code for responding to application-level events raised by ASP.NET.
.aspx An ASP.NET Web Forms page that can contain Web controls and presentation and

9 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE
business logic.
.config A configuration file contains XML elements that represent settings for ASP.NET
features.
.cs, .vb Source code files (.cs or .vb files) that define code that can be shared between pages,
such as code for custom classes, business logic, HTTP modules, and HTTP handlers.
.dll A compiled class library file (assembly). In a Web site project, instead of placing
compiled assemblies in the Bin subdirectory, you can put source code for classes in
the App_Code subdirectory.
.master A master page that defines the layout for other Web pages in the application.
.mdb, .ldb An Access database file.
.mdf A SQL Server Express database file.
.skin A skin file that contains property settings to apply to Web controls for consistent
formatting.
.sln A solution file for a Visual Studio project.

WEB FORM ROUND TRIP


• The browser presents the user with a form, and the user interacts with the form, causing the form to
post back to the server.
• However, since all processing that interacts with server components must occur on the server.
• So this means that for each action that requires processing, the form must be posted to the server,
processed, and returned to the browser. This sequence of events is referred to as a round trip.
• In Web Forms, most user actions such as clicking a button result in a round trip.
• For that reason, the events available in ASP.NET server controls are usually limited to click-type events.
• Most server controls expose a click event, one that requires an explicit user gesture.

10 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE

STAGES IN WEB FORM PROCESSING *


• When a user request for Asp.net page, the page gone through many stages that is call its life cycle.
• Various stages in ASP.Net Web Page

Page
request

Unload Start

Rendering Initialization

Load

Stages What is done in Stages?


Request Asp.Net checks that request of the page is new or old, if new then it
Page Request
compiles and executes that page and if request is old, cached copy will be returned.
Request And Response properties are set and using IsPostBack property new or old
Start
request can be identified.
In the Initialization phase, controls are available on the page. Every control has
Initialize
Unique ID property.
During the load phase, the request is post back and control properties are loaded
Load
with information.
The view state of the controls on the page is saved before rendering on the server.
Rendering
The page calls the Render method for every control.
Request and response properties of the page are unloaded and cleaning performed if
Unload
required.

ASP.NET OBJECTS (REQUEST, RESPONSE, SERVER, APPLICATION, SESSION)


• Request Object: - Describes the methods, properties, and collections of the object that stores
information related to the HTTP request. This includes forms, cookies, and server variables.
• Response Object: - Describes the methods, properties, and collections of the object that stores
information related to the server's response. This includes displaying content, manipulating headers,
setting locales, and redirecting requests.
• Server Object: - Describes the methods and properties of the object that provides methods for various
server tasks. With these methods you can execute code, get error conditions, encode text strings,
create objects for use by the Web page, and map physical paths.

11 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura


Unit-1 Introduction to ASP.NET web
programming & IDE
• Application Object: - Describes the methods, properties, and collections of the object that stores
information related to the entire Web application, including variables and objects that exist for the
lifetime of the application.
• Session Object: - Describes the methods, properties, and collections of the object that stores
information related to the user's session, including variables and objects that exist for the lifetime of
the session.

CONCEPT OF POST BACK in ASP.NET:


• As we had studied page_load event fires every times a web page is loade.
• But sometimes you want code to run only the first time a page is loaded.
• You can check to see whether this is the initial loading of the page by querying the IsPostBack property
of the Page Object.
• This property will returns False the first time if the page is loading and it will returns a true if the page
is already loaded once.

12 Dept: CE AWT (3360706) Prof. Akash N. Siddhpura

Você também pode gostar