Вы находитесь на странице: 1из 31

Home

Presentati
on
on

ASP . Net
Home CONTENTS

Subject Slide No.

• .NET Framework 3
• Introduction to Asp.Net 4
• Overview 5
• Asp.Net Features 6
• Asp.Net Page structure 9
• Event Handlers 12
• Web Form Page Life Cycle 13
• Script Section 14
• HTTP Handlers 17
• Server Controls 18
• Web Server Controls 19
• Working with Web Objects 21
• Web Services 27
• A Word of Thanks 29
1
Home .NET Framework

The Way in which Programs are Executed in .NET


.NET Application code is compiled into Microsoft
Welcom
e Intermediate
.NET Class
Language (MSIL) and stored into a file called DLL.
Library
Applications
that run under Common Language Runtime (CLR
Compiled into
an execution
engine ) are called managed Code as it provides
assembly
JIT. At run
Common Language Runtime(CLR)
time the Assembly is compiled to its final state by
DLL the CLR.
Compiled into native code
While
(in MSIL) running the CLR provides memory
management, Executes
type-safety checks, and other run-time tasks for
User
the Application.
2
Home Introduction to Asp.NET

q ASP.NET is a part of the


Microsoft .NET strategy
for Web development.
q It is a Web development platform
that provides
the services necessary for
developers to build
enterprise-class Web applications.
q It applies an object-oriented
3
Home Overview

An Asp. Net Web application response from server resources

Executable

Server
Receives Composes
1 Request
2 Response Server
Resources
Welcome :

Welcome.a
spx
/img
 
3 Returns Response Data Store
.
  .
  .
 
 
 
4
Home ASP.NET Features

Supports multiple programming


languages
ASP.NET

supports

Other
VB.NET C# JScript languages

Web Application
5
Home Advantages of ASP.NET

q A new development interface


under Visual
Studio.NET.
q Separation of code and
presentation logic for better
understanding and maintenance.
q Extensive language support like
Visual Basic .NET, C#, Jscript
and ADO.NET.
6
Home Detail Overview

Asp. Net Web application parts interaction on a Web


Server
Internet Information Services
(IIS)
IIS Starts Application
1
IIS Returns
3 Response 2 Application composes
Response

Web.config
Welcome Server resources:
Style Sheet
(CSS) Welcome.aspx
FindTitles.aspx
System.aspx
/img
Pubs Database
.
.
.
7
Home Asp.NET page structure

Page files are text files with an


extension .aspx or .ascx

Implements application logic using


server-side code

Presents information to the user in


8
Home ASP.NET Pages

Static Text and Controls


WebForm

WebForm.aspx WebForm.aspx.cs

Visual component Logic (code


(Usually Contains behind)
HTML and JScript)
User interface in the
Both files together make up a WebForm browser
9
Home Page Directives
@Page: Defines page-specific attributes used by the ASP.NET page parser
and compiler. Can be included only in .aspx files.

@Control: Defines control-specific attributes used by the ASP.NET


page parser and compiler. Can be included only in .ascx files (user controls).
@Import: Explicitly imports a namespace into a page or user control.
@Implements: Declaratively indicates that a page or user control
implements a specified .NET Framework interface.

@Register: Associates aliases with namespaces and class names,


allowing user controls and custom server controls to be rendered when

included in a requested page or user control


@Assembly: Declaratively links an assembly to the current page or user
control.
@OutputCache: Declaratively controls the output caching policies of a
page or user control.

@Reference: Declaratively links a page or user control to the current


page or user control.
10
Home Event handlers

An Event handler is a subroutine


that
executes code for a given event.
Events are raised during each
stage of a
Web Form processing.
The event handler that corresponds
to
the raised event runs.
11
Home Web form page life cycle

Stage Event Raised


Page
Initialization Page_Init
Some events are fired automatically by the
User Code
Initialization
page during Page Load
some specific stages of page processing.
Validation Others that Validate
are associated with server controls are
Event triggered
Handling Form event handler
on the client but are fired and handled on the
Before Page server.
rendering Page_PreRender

Cleanup Page_Unload
12
Home Script section

Script section

Server-side script Client-side script

Executed by the server Executed by the browser

C# Jscript

VB
13
Home Client side script

They are part of a page and are sent to


the browser which executes them when a
user requests the page.
Typically used to:
Change the appearance of the page when it is
loaded in the browser
Perform validation on the data entered by the
user in a form
Display relevant information in the browser
14
Home Server side scripting

Code can be contained in either


server-
side <script> code declaration
blocks or
<% %> render blocks .
ASP.NET supports server-side code
in any
language that targets the runtime.
<script runat="server" [language="C#"]
Server-side code declaration blocks
src="scriptfile" />
must
15
Home Http Modules
Http handlers

Every request in ASP.NET is


HttpModules are Similar to ISAPI Filters

processed
They are builtby
• an.NET
using
•The Integrate with the ASP.NET Request
HttpHandler
Pipeline
The Pipeline is over 20 events that
For example, ASPX pages are
o

fire during the processing of a


handled by the default
request.
•Used to ‘Catch’ the Request and React as

ASPX
needed. Page HttpHandler.
URL Rewriting
You ocan create your own
o

Security
HttpHandler
o
Logging to render
content based on the request
16
Home server Controls

1. Flexible controls.
2. Not many features.
3. Used when the form runs in the client
HTML controls side and user does not need many
features to be incorporated.
4. Useful when porting ASP applications
to ASP.NET.

1. Rich features that enable programming


of controls
2. Large variety of controls present.
Web controls 3. Used when the form runs
in the server side.
4. Better functionality to handle data
stored in the database
5. Useful in visual design environments.
17
Home Web server controls

qASP.NET provides a set of object-


oriented GUI
components known as Web Server
Controls to
design and develop a web
application apart from the
HTML controls generally used to
design web
applications.
18
Home Web server controls

The AutoPostBack property can be found in all web


server
controls which post back their data to the server
when the
form is posted or when a button is clicked.
The EnableViewState property can be found in all
web server
controls and is used to define whether a control’s
ViewState or
the present value it contains is to be retained in the
control
after the form is posted back to the server.
Web Server Controls can be classified as:
Text Entry Controls
19
Home Working with web objects

Namespaces
Using the Request Object
Using the Response Object
Retaining value of Variables
Session and Application State Variables
Configuration Files
Web.config File
20
Home Working with web objects

Namespaces :

• System.Web : The Application, Browser, Cache, Cookies,


Exception, Request, collection of similar classes
Namespaces
Response,
Namespaces Server,
are and Trace
a way Objects. code.
of organizing Use these Classes in
They provide
most Web from
protection
Programming tasks. The Application object defined in
Global.asax is basedsometimes
conflicting names, on called namespace collisions.
the
ThisApplication
protection class.
is
especially
• necessary in large projects
System.Web.SessionState : The in which it isobject.
Session very easy
These
for two items
classes are used to
retrieve and save
to accidentally items
have the in Session
same name.state.
By organizing your code
Topic into namespaces,
Hom
• System.Web.Services : The WebService object. These
e classes
you are referred
reduce to of these conflicts.
the chance
create and use Web Services.

• System.Web.UI : The Page and Control objects. These


classes are used in
20
Home Working with web objects

Page
• The Page Object Controls your
Cache
Application’s user Interface. The Page object
has properties and methods that provide
access to other objects in the user interface.
Controls

Request
• The Page base class provides the core
methods and properties that you use
Response
frequently when programming Web forms.
Server

Session

Trace
21
Home Working with web objects

Using the Request Object

Request
The Request Object contains the
information sent by the client
Browser
browser when a page is
Determine requested
the Capabilities of
the Browser making the
Client
from the application.
Certificates TheBrowser
request. Requestproperties
provide the browser version
has properties
Cookies
and methods
Authenticate
number, that
the Client
determine if it
supports cookies, and supply
provide access to otherother objects
Information. that
Get Information from the
Topic
Hom
make up the request,
Files as
Read
client shown
inand
theWrite
form to inraw
of the
Cookies
data sent in the request
e the figure. Get Files that are Uploaded
InputStream by the Client
The HttpRequest object
encapsulates information that the
22
Home Working with web objects

Using the Response Object

Response
The Response Object contains the
information sent by the client
Cache
browser when a page is requested
from the application.Determine
The Request
how the server
Cookies caches responses before
has properties and methods
they
Set theare
Content that
sent to
of the clientto
cookies
provide access
Output
to other objects
send to the client

Topic
Hom
that make up the request,Get or setas
the raw data
returned to the client as the
e shown in the figure. response

HttpResponse object gives the


developer access to the output
23
Home Working with web objects

Web forms are created and


destroyed each time a client
browser makes a request. Because
Context.Handler object : This object is used to retrieve
ofpublic
thismembers
characteristic,
of one Web form’s variables
class from a
declared
requests and responses as part of theform
subsequently
Query
within
strings displayed
a Web
Web form.
: This is used
do not
to pass information between
Web address. They
retain their
are visible
information
value
to the user,
such as
after
so they
passwords.
should anotpage is
contain secure
Cookies : They are used to store small amounts of
displayed.
Information on aTo solve
Client. thisrefuse
Client might problem,
cookies, so
the code has to anticipate that possibility.
Asp.
ViewNetState provides
: ASP. Net storestheitems following
added to a page’s
Topic
Hom ways to
ViewState retain
property variable
as hidden fields onbetween
the page.
Session state : The Session state variables are used to
e
requests:
store items that you want to keep local to the current
session ( single
Application user: ).
state The Application state variables to
store items that you want to be available to all users of the
application.
24
Home Working with web objects

“Global.asaVariables
Page-level
x” Object-level
*String
Contains configuration
ourname settings for all
= “nobel"; Application
applications. ("Welcome " +
Response.Write Level
ourname); Session Level
* Stores event handlers for all events

* Stored in the root directory of the application


Topic
Hom * Its location defines the boundary for the application
e
25
Home Working with web objects

Session & application state variables


Session Management can be
Application
done in
and Session state
variables
3 ways : are created on
the fly,
• withoutInProc
Inproc variable name
is the default or
and easiest
type checking.method.
We
and
Theyet
It’s a good entry-level
still powerful
StateServer is away to
Windows
• StateServer maintain state.that
services It’s operates
also very
should limit the access points to
performant. Data
Theindependently
most powerful of
in web
the
comes
the site’s
from
session is stored in thedosame
these variables.
SqlServer
• SQL Server as a state server.require
app domain. Objects It
memory space as
serialization, the
however,
involves a bit of overhead due to
application.
performance is very good. The
Topic serialization and data retrieval,
Hom Maintaining Session state affects
state the
however, server can live onisone
performance stillof
e the
quite web servers,
good. and other web
Many customers
performance. Session servers
already have can point to it so SQL
large/redundant the
client canso
deployments, connect to multiple
leveraging this
state can be turned off at the
servers and
infrastructure receive
is an the same
advantage.
state.
26
Home Working with web objects

Configuration files
q
Configuration files are stored in plain text, which enables
Configuration Files
web developers
to edit
q The themconfiguration
ASP.NET in any text-editor of their
files are choice.
written in XML, which
enables the
developer to modify them using an XML parser too
q If the configuration settings are changed, they are
Type of Tag Rule
automatically detected
by theattribute Camel-case
system. The
Machine.Config
Tag and server: need
The first character
Web.Config
not of a tag name is
be restarted.
lowercase and the first letter of any subsequent
names
Server Configuration words
File are in uppercase.
q Each directory can actually override the configuration of
Pascal-case : The first character is uppercase and the
the previous first letterContains
of any subsequent
propertyconcatenated
settings words
just is
Attribute values
directory by creating its own configuration file.
It sets properties
Topic applicable
uppercase.
q The clients cannot view the contents
Exceptions
for being
a single
of true Directory
and false,
application
the or which
configuration
are in lowercase. Sub
Homfor the entire server,and even may be a single Directo directory
e files using a
is an XML based
browser, fileensuring security.
thus, of an application. ry
27
Home Working with web objects

Configuration files
Web.Config File
Set the
Structure
<configuration> Property
<configSections>
Values
<section name="sectionSettings" Root />
type="Class"
This web.config
<sectionGroup is an XML
name="sectionGroup">Directory
based
<section
An Web Pages
file is configured
name="sectionSettings"
application
type="Class" /> Of
using the ‘web.config’ file which residesApplication
</sectionGroup>
in Application
the root directory
Configuration
of the application.
</configSections>
File
<section name="sectionSettings" type="Class" />
<sectionGroup> ‘Web Config’
<sectionSettings attribute="someValue" />
‘ Web.Config’
<sectionSettings SomeAttribute="SomeValue">
Topic
Hom <element attribute="value">
</sectionSettings>
e
</sectionGroup>
</configuration>
Home A word of thanks . . .

Thanking You . . .

Amit Sharma

Kanhaiya Kumar Jha

Pawan Mishra

Sayanta Basu

Sribas Das

Tanmoy Guha

Вам также может понравиться