Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 29

Globalization and Optimization

Pre-Assessment Questions
1. Which of the following is not a client-side option?

a. Query strings
b. Hidden Fields
c. View state property
d. Session state

2. The __________ property of an ASP.NET Web page enables you to retain


page and control-specific values between round trips.
a. ViewState
b. HTTPForm
c. HttpUtility
d. UrlEncode

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 1 of 29


Globalization and Optimization

Pre-Assessment Questions (Contd.)

3. Which of the following actions does the built-in session state feature not
automatically perform?
a. Store session-specific data on the server for use across multiple
browser requests.
b. Stores the information in the application state in a key-value pair and
maintains data consistency between server round trips and between
pages.
c. Raise session lifetime-related events, such as Session_OnStart and
Session_OnEnd, which can be handled using application code.
d. Automatically release session data if a browser does not access an
application within a specified timeout period.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 2 of 29


Globalization and Optimization

Pre-Assessment Questions (Contd.)


4. Which of the following is a disadvantage of the session state?
a. A session state facility can work with browsers that do not support
HTTP cookies.  
b. Session state variables are stored in memory until they are either
removed or replaced.
c. Session state requires server memory and can affect the
performance of the server and the scalability of the Web session.
d. The data stored in an session state is lost when the Web server
containing the session state fails due to a server crash, upgrade, or
shutdown.
5. Which of the following statement is against accessibility guidelines?
a. Every page in an application should have a style sheet attached to it.
b. Every image should have an alternate text.
c. Every link should have a tool tip.
d. Use consistent navigation method.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 3 of 29


Globalization and Optimization

Solutions to Pre–Assessment
Questions
1. d. Session state
2. a. ViewState
3. b. Stores the information in the application state in a key-value pair and
maintains data consistency between server round trips and between pages.
4. b. Session state variables are stored in memory until they are either
removed or replaced.
5. b. Every page in an application should have a style sheet attached to it.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 4 of 29


Globalization and Optimization

Objectives
In this lesson, you will learn to:

• Implement Globalization
• Optimize Web applications
• Implement caching
• Use resource files
• Develop a Locale-Aware application

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 5 of 29


Globalization and Optimization

Globalization in ASP.NET

• International applications should be customizable according to the preferences


of users belonging to different nations, cultures, or regions. User preference
refers to the language, currency, and date formats.
• The structure of an internationalized application is divided into two blocks:
• Code block
• Data block

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 6 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• Internationalization includes three phases:
• Globalization: Involves writing the executable code for an application in
such a way that makes it culture-neutral and language-neutral.
• Localizability: An application that has been globalized must be tested to
ensure that its executable code is independent of the culture and
language-specific data.
• Localization: Involves the customization of an application for a specific
locale. One major task in this phase is the translation of resources
identified during the globalization phase.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 7 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)

• The three phases of internationalization are shown in this figure:

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 8 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• The System.Gloablization namespace provides different classes that enable
you to determine locale-specific information, such as the language and country
of an application at run time.
• You can implement globalization by:
• Using the CultureInfo Class: The following are some of the commonly used
properties of the CultureInfo class:
• CurrentCulture
• CurrentUICulture
• DisplayName
• EnglishName
• Name
• LCID

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 9 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• Character Encoding
• Encoding is the scheme for representing characters in a numeric
format. The characters from different languages are grouped into a
set called a character set.
• There are two very commonly used character sets. They are:
• American National Standards Institute (ANSI): Includes 256
characters and punctuations. In ANSI, every character is
represented using one byte (8-bit).
• Unicode: In Unicode, every character is represented using 2
bytes (16-bit).

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 10 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• Mirroring
• While creating internationalized Web applications, you need to
consider the fact that there are languages that are read from the
right to the left. In case of Right-To-Left (RTL) languages, the
alignment of text and the layout of different UI components, such as
menus and buttons, are reverse of the normal flow.
• Mirroring is the transformation of coordinates.
• Validating Nonlatin User Input
• A language that does not follow the Latin script is called a nonlatin
language.
• The Char structure exposes some validation methods that can be
used to determine the category of a nonlatin alphabet input in the
same way as a Latin alphabet input.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 11 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• Working With Resources
• A resource is any non-executable data that is logically deployed with
an application.
• A separate resource file should be created for each culture for which
the application is to be customized.
• You can use the Resource File Generator (ResGen.exe) command
prompt utility to convert a resource file in the text format into the
binary format.
• The output of creating resource-only assemblies will be a DLL file,
which will contain all the resource files you added.
• Satellite assemblies are resource-only assemblies that contain only
culture-specific resources.
• The System.Resources namespace provides different classes, which
enable you to retrieve values from resource files.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 12 of 29


Globalization and Optimization

Globalization in ASP.NET (Contd.)


• Configuring a Web Application for Globalization:
• In ASP.NET, you can use the Web.config file to configure an application for
globalization.
• The <globalization> tag has the following attributes:
• requestEncoding
• responseEncoding
• fileEncoding
• culture
• UiCulture

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 13 of 29


Globalization and Optimization

Optimizing Web Applications


• Optimization is a key phase in the lifecycle of a Web application. The primary
objective of this phase is to improve the performance of a Web application.
• Optimization includes the following steps:
• Collecting data
• Analysis of data
• Investigation
• Planning
• Implementation

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 14 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• The entire optimization process is divided into three levels:
• System-level optimization: Focuses on investigating and solving system-
level performance issues, such as hardware and platform-related
performance bottlenecks.
• Application-level optimization: Focuses on investigating and solving
application-level performance issues, such as state management, data
access, and architectural issues.
• Modular-level optimization: Focuses on investigating and solving modular-
level performance issues, such as memory leakage, I/O operations, and
request processing.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 15 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching
• Caching is a technique used to resolve the problem of slow access.
• This technique improves the performance of any Web application by
temporarily storing frequently used Web objects, such as HTML pages, on
local hard disks for later retrieval.
• The data can be cached either at the client side or at the server side. The
different locations at which data may be cached are:
• Client
• Dedicated server
• Reverse proxy
• Following are the benefits of caching:
• Reduced access time
• Less bandwidth required
• Less load on server

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 16 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching
• ASP.NET supports three types of caching based on the unique concept of
storing data or a part of the data for later use to enhance the performance
of a Web application:
• Output Caching
• Fragment Caching
• Data Caching

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 17 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Output Caching
• In this type of caching, the content of the entire page is cached.
• To implement output caching, you need to specify the expiration policy for
pages, which specifies the time for which the cache data remains valid.
• Using the @ OutputCache Directive: The @ OutputCache directive takes
the following attributes:
• Duration
• Location
• VaryByParam
• VaryByCustom
• VaryByHeader
• VaryByControl

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 18 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Output Caching
• The HttpCachePolicy class can be used to implement the output cache
for a page.
• HttpCacheability takes the following possible values:
• NoCache: The output will not be cached.
• Public: The output can be cached on the client side as well as on the
proxy server.
• Private: The output can be cached only on the client side, as it is a
default value.
• Server: The output can be cached only on the Web server.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 19 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Fragment Caching
• Fragment caching is used in situations where the Web page contains
dynamic data.
• To implement fragment caching, the portions of the page that you want to
cache must be encapsulated in a user control.
• The HttpCachePolicy class can also be used to implement fragment
caching for a page.
• Although fragment caching does not provide as much performance
improvement as output caching does, but it still speeds up the response
time

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 20 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Data Caching
• Data caching is used to access frequently used data that is cached in the
server-side memory variables.
• Using the Cache Object: The Cache object stores and retrieves data items
from the cache as easily as you store and retrieve items from the
dictionary class.
• Using the Cache object to cache data, data will remain in the cache either
for the lifetime of the application or until it is removed explicitly.
• To control data caching more effectively, there are two more methods.
They are:
• cache.insert
• cache.add

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 21 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Data Caching
• Using the Dependency Option: You can use this option to link the cached
copy of an object to the real object.
• Using the Expiration Policy Option: The expiration policy may be either
absolute expiration or sliding expiration.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 22 of 29


Globalization and Optimization

Optimizing Web Applications (Contd.)


• Understanding Caching: Data Caching
• The priority option is used to specify the priority of an item.
• The permissible value to the CacheItemPriority is as follows:
• Low
• Normal
• Below Normal
• Above Normal
• High
• NotRemoveable
• Second option
• Never
• Fast
• Medium
• Slow

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 23 of 29


Globalization and Optimization

Creating a Web Form in ASP.NET


• Problem

Create an ASP.NET application that is locale-aware. You need to


create resources for four cultures, en-US, es-ES, fr-FR and
ru-RU. The application will load resources based on the culture
selection made by the user.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 24 of 29


Globalization and Optimization

Creating a Web Form in ASP.NET


(Contd.)
• Solution

1. Create an ASP.NET Web application.


2. Design the Culture Web form.
3. Create four resource files under the Resources folder.
4. Add functions to the Culture Web form.
5. Create the Message Web form
6. Run the program.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 25 of 29


Globalization and Optimization

Summary
In this lesson, you learned:

• The process of making an application ready for an international


customer is called internationalization. It includes three phases:
• Globalization
• Localizability
• Localization
• The different aspects of an application that should be considered in the
localization process are:
• Formats
• Graphics
• Validation rules
• The System.Gloablization namespace provides different classes that
enable you to determine locale-specific information, such as the
language and the country of an application at run time.
©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 26 of 29
Globalization and Optimization

Summary (Contd.)
• The System.Gloablization namespace provides different classes that
enable you to determine locale-specific information, such as the language
and the country of an application at run time. In ASP.NET, the DataGrid
control is used to display XML data in a grid.
• The CultureInfo class is in the System.Globalization namespace that
identifies the locale by a culture.
• Some of the commonly used methods of the CultureInfo class are:
• GetCultures
• GetFormat
• Encoding is the schema for representing character in a numeric format. The
characters from different languages are grouped into a set called the
character set. There are two very commonly used character sets, American
National Standard Institute (ANSI) and Unicode.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 27 of 29


Globalization and Optimization

Summary (Contd.)
• Mirroring is the transformation of coordinates for the languages that are read
from the right to the left.
• A language that does not follow the Latin script is called a nonlatin language.
• A resource is any nonexecutable data that is logically deployed with an
application.
• Optimization is to improve the performance of a Web application.
• The entire optimization process is divided into three levels:
• System-level optimization
• Application-level optimization
• Modular-level optimization
• Caching is a a technique for optimizing a Web application.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 28 of 29


Globalization and Optimization

Summary (Contd.)
• ASP.NET supports three types of caching based on the unique concept of
storing data or a part of data for later use to enhance the performance of a
Web application:
• Output Caching: Enables you to cache the entire page so that the page
does not require to be created again for every request.
• Fragment Caching: Used in situations where the Web page contains
dynamic data. It allows you to cache only certain portions of a Web
page. These are the portions that remain static most of the time.
• Data Caching: Used to access frequently used data that is cached in the
server-side memory variables.

©NIIT Developing Web Applications Using ASP.NET Lesson 4B / Slide 29 of 29

You might also like