Asp.net slide
Trang 1Session 19
Configuring an Application in ASP.NET
Trang 2 A service has two characteristics: Interface and Registration
Web services reduce the “communication-gap” among the Web applications,
enhancing interactivity Web sites thereby group together to form a constellation, providing users a rich user experience
Advantages of Web Services
Cross business integration
Improved efficiency
Closer customer relationships
Facilitation of just-in-time integration
The extension of a Web service file in NET is asmx
The [WebMethod] tag notifies the ASP.NET compiler that the method to follow should be a Web method, which is to be exported onto the Web
Trang 3 WSDL is the short form for Web Services Description Language WSDL is the
grammar for a Web service, or moreover, could be thought of as a language that describes or portrays a Web service
The proxy class does not contain any application logic Instead, it contains the
transporting logic as to how the parameters would be passed, and the result
retrieved
The proxy class will also contain a list of all the methods that are present in the Web service and their prototypes
UDDI is the abbreviation for Universal Description, Discovery and Integration
UDDI helps in registering the services provided by the service providers, so that
they can be shared It also helps the service consumers or Web users in locating the Web services
Trang 5Web Pages – Web
Application
Individual web pages together form a web application
Advantage of grouping individual pages together into an
application, is that values can be set for all these pages at
once, by setting the properties of the application
The setting of values for the properties of an application
that will control the application at runtime, is known as
configuring the ASP.NET application
Web Page Web Page
Web Page Web Page
Web Page - -
WEB APPLICATION
Trang 6ASP.NET provides the configuration files that are needed to
customize the web site These files offer remarkable flexibility
to the web applications
Trang 7Features of Configuration Files
Stored in plain text format
Written in XML Rules for naming tags and attributes
No need to restart server in case of changes
Trang 8Rules for naming the Tags
Pascal-case : first character is
uppercase, and the first letter of any subsequent concatenated words is
uppercase Exceptions being true and
false, which are in lowercase.
Attribute values
Camel-cased : First character of a tag
name is lowercase, and the first letter
of any subsequent words is uppercase Tag and attribute names
Rule Type of Tags
Trang 9Types of Configuration Files
Only one file per ASP.NET installation on a machine
XML based file stored in the web application directory of the
web server
One file per each directory of the web application
Trang 10Types of Configuration Files –
Contd…
Web
Applications
One per machine
One per application
Override settings of machine.config
Trang 11Structure of Configuration
Files
The configuration file encloses all the tags within the
configuration tags, which if not done, the compiler throws
an exception
The configuration properties of the machine are set
between these tags
Within the configuration tags, the configuration
information is grouped into two categories:
configuration section handler declaration area
configuration section settings area
Configuration sections are defined between
<configSections> and </configSections> tags
The individual sections are defined using the <section>
tag
Trang 13Configuration Section Handler Declaration Area
Defines a class (usually a NET base class) that
will be used to interpret the configuration data
This section is enclosed between the
<configSections> tag
Generally, this section is placed in the
Machine.Config file, and need not be placed in
each and every Web.Config file, as it will be
inherited automatically (from Machine.Config)
Trang 14Configuration Sections Settings Area
Defines the actual settings for some particular
option
Contains the section handlers in which the
configuration code is written
Each of the section handlers is grouped in a
<sectionGroup>, that offers a structure to
the configuration file
There are around 30 different configuration
settings already defined in the Machine.config
file
Trang 15Page Configuration Settings
The page configuration settings allow the developer to control
some of the default behaviors for all the ASP.NET pages in the
Buffer
Default Value Description
Property
Trang 16Application Setting
The application settings section is enclosed between the
<appSettings> and </appSettings> tags
These settings allow the user to set the application configuration details.
Application settings enable to store and retrieve information as value pairs
key- It is also possible to store, SQL queries
Trang 17Compilation
Setting
The compilation settings section is used to specify the compilation options that
are necessary to compile the application source files
References of the assemblies that are required during compilation can be
specified here
It is also possible to specify whether to run the application in a debug mode
Provides a semicolon separated list of language ‑names to use in a dynamic compilation of files For example, "C#; VB"
Attribute
Trang 18In the compilation section, the debug property is set to
false, and at the same time the default language is set to
C#.
Trang 19Sub-tags of Compilation tag
Trang 20Sub-tags of Compilation tag
Trang 21Sub-tags of Compilation tag Contd…
<compilers> sub-tag
<compilers> sub-tag is used to specify the compiler and the language that
is used to create the application
Trang 22customErrors Setting
ASP.NET provides the flexibility to write custom error
pages, and redirect the browser (client) to these error
pages when any specific error occurs
The error pages to be displayed can be designed to give a more polite and user-friendly explanation of the error and its cause
Trang 24Exploring ASP.NET / Session 19 / 24 of 31
The process of identifying the valid user/password, and providing services
accordingly, is known as Authentication The settings can be specified in the
web.config file itself
Trang 25Authentication Types
Specifies Windows authentication as default authentication mode Used for any form of IIS authentication
Specifies ASP.NET forms-based authentication as default authentication mode Widely used method
Specifies Microsoft Passport authentication as default authentication mode
No authentication Used by anonymous users and applications providing own authentication
WINDOWS
FORMS
PASSPORT
NONE
Trang 26Attributes of <forms>
tag
Validation scheme verifies whether the contents of an
encrypted cookie have been altered in transit Validation
Cookie should not be stored as plain text but should be encrypted for protection
Attribute
To use Form Authentication, the authentication mode needs to be specified as
Forms, in which case the <forms> sub-tag can be supplied having following
attributes
Trang 27Attributes of <forms> tag
Path for cookies issued by the application Default value
Attribute
Trang 28Forms Authentication Example
<user name="User1" password="user1!"/>
<user name="User2" password="user2@"/>
<user name="User3" password="user3#"/>
Trang 29 After setting the authentication settings for an
application, access rights need to be assigned
as to who can access the application
Setting these access rights is known as
Authorization
Using Authorization settings, users are actually
authorized to access the website
<authorization>
<allow users=“<userList>” />
<deny users=“<userList>” />
</authorization>
Trang 30<user name="User1" password="user1!"/>
<user name="User2" password="user2@"/>
<user name="User3" password="user3#"/>
Trang 31 ASP.NET is a collection of all the ASP.NET pages, the custom
controls and modules
It provides the configuration files to customize the web site.
The ASP.NET configuration files are written in XML, which enables
the developer to modify them using an XML parser.
Two types of configuration files exist in ASP.NET:
Machine.Config
Web.Config
A hierarchical structure can be formed with every directory,
configuring the files present within them, with their own Web.Config files.
Trang 32Summary Contd…
Within the configuration tags, the configuration information is
grouped into two categories:
The configuration section handler declaration area
The configuration section settings area.
The process of validating the user name and password is known as
Authentication