review materi asp.net
TRANSCRIPT
3SC – Q6 Dudy Fathan Ali S.Kom
Review Materi ASP.NET3SC – Q6
Dudy Fathan Ali, S.Kom (DFA)2014
CEP - CCITFakultas Teknik Universitas Indonesia
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Consuming Web Services in a Web Application
Web services are the application components that can be used by other Web applications. You can create a Web service and publish it on a Web server, thereby, making it available for other Web applications to use.
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Invoking Web Services
A Web service:Is a self-describing Web component that exposes its functionality to the consumers through open standards such as XML and Simple Object Access Protocol (SOAP). Is a widely used method for implementing Service-Oriented Architecture (SOA). Allows integration of applications developed in different languages and running on different platforms. Communicates by using a standard protocol called SOAP. SOAP defines a standard way of passing the XML-encoded data.
Developing ASP.NET Web services starts by creating an .asmx file and hosting it on a Web server, such as IIS. A Web service once hosted or published on the server can be consumed by any client.
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Invoking Web Services
The client locates the service by adding a Web reference. This adds a proxy class on the client side, which exposes the methods, parameters, and return types of the methods contained in the Web service. After adding the proxy class, the client application creates an instance of the proxy class and accesses the methods provided by the Web service through the instance.The client requests are then handled by the proxy class. After processing the request, the response is also sent as a SOAP message to the proxy. The proxy then converts this SOAP message into method return value, which is returned to the client.
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Invoking Windows Communication Foundation Services
In distributed computing, Web services along with various other technologies, such as COM+, .NET Remoting, Message Queues, and Web Service Enhancement (WSE) were used to provide a wide range of functionality. WCF:
Unifies features of such discreet technologies under one single framework. Provides a unified programming model used to build a secure, reliable, and robust Web service.Aims at providing encoding, hosting, messaging patterns, networking, security, and interoperability in a single infrastructure.
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Invoking Windows Communication Foundation Services
The following figure shows the WCF architecture.
Consuming Web Services in a Web Application
3SC – Q6 Dudy Fathan Ali S.Kom
Invoking Windows Communication Foundation Services
The following set of APIs is unified in the WCF architecture:ASP.NET Web Services (ASMX)WSESystem.MessagingEnterprise ServicesRemoting
The design goals for building WCF services are: UnificationInteroperabilityService orientation
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
AJAX is a technology, which when implemented in Web applications makes the interaction between the client and the server asynchronous. AJAX implementation:
Allows users to interact with the Web application while waiting for a response from the server. Enables partial updates in Web applications.
Explaining the AJAX Framework
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
AJAX is a Web development technique that:Is used for creating dynamically interactive applications. Enables Web applications to retrieve data from the server, asynchronously in the background, without interfering with the display and behavior of the existing page.
To understand the concept of AJAX, you need to understand the relevance of the following terms:
Asynchronous communicationJavaScriptXML
Understanding AJAX
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
AJAX-enabled Web applications offer: Quick response to a user’s requestAsynchronous communication that allows a user to interact with the rest of the Web page while the application is processing the changed or updated parts of the Web pageAuto-generated proxy classes that are used to call Web service methods from client script such as JavaScriptSupport for the widely used Web browsers such as Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari
Advantages of AJAX-Enabled Web Applications
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
Some of the limitations of AJAX-enabled Web applications are:
Browser IntegrationDependency on JavaScript
Limitations of AJAX-Enabled Web Applications
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
The ASP.NET AJAX Web applications consist of client-side and server-side scripts. The following figure displays the ASP.NET AJAX architecture.
Architecture of ASP.NET AJAX
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
Architecture of ASP.NET AJAX
The preceding figure shows that the ASP.NET AJAX architecture consists of the following components:
Client-based Microsoft AJAX library Server-based AJAX features for ASP.NET
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
Architecture of ASP.NET AJAX
Client-based Microsoft AJAX library:The ASP.NET AJAX client architecture provides features that enable you to create rich, intuitive, responsive, and interactive Web applications. This architecture includes the ASP.NET AJAX library that includes:
ComponentsBrowser compatibilityNetworking Core services
Creating Rich Internet Applications Using AJAX
3SC – Q6 Dudy Fathan Ali S.Kom
Architecture of ASP.NET AJAX
Server-based AJAX features for ASP.NET:The ASP.NET AJAX server architecture provides the functionalities for the following server-based AJAX features:
Script supportWeb servicesApplication servicesServer controls
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Internationalization
To make an international application customizable, you need to understand the following phases that are involved in developing an internationalized application:• Globalization: Globalization is the process of designing and
developing a Web application in such a way that it is culture-neutral and language-neutral.
• Localizability: Localizability is an intermediate process that ensures that a globalized Web application is ready for implementing localization.
• Localization: Localization is the process of customizing the globalized Web application to a specific locale and culture. In this phase, various resources, such as images and text, for the designated locale are created.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Factors Related to Creating International Applications
Application developers need to attend to locale considerations when they develop international applications because negligence of these considerations can lead to issues. The factors that need to be considered while designing an internationalized applicationare:• Language issues• Formatting issues• String-related issues• User-interface issues
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Factors Related to Creating International Applications
Language issuesLanguages around the world differ in display, alphabets, grammar, and syntactical rules. For example, some languages such as Arabic are written from right-to-left, whereas other languages are written from left-to-right. Some languages include uppercase and lowercase characters, whereas others do not even have the concept of uppercase and lowercase. Languages differ in the number of characters, storage requirements, keyboard layouts, and code representations. This diversity makes it difficult to share data between cultures. It is even more difficult to create a multilingual user interface.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Factors Related to Creating International Applications
Formatting issuesFormatting is the main source of differences in applications designed for multiple languages or cultures. Formatting differences may arise in the addresses, currency, dates,numerals, telephone numbers, time, and units of measure of various languages.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Factors Related to Creating International Applications
String-related issuesWhen developing international applications, programmers must consider issues related to strings. When strings are translated from one language to another, the translated strings may be longer than the original strings. In strings, the order of alphabets varies in different languages. This causes major problems in sorting and comparison of strings. Issues also arise when strings are concatenated because these strings may convey different meanings in different languages.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Factors Related to Creating International Applications
User-interface issuesVarious user interfaces are associated with the design of an international application. The size of user interface elements should be larger than that required for accommodatingEnglish strings. This is because strings in other languages are usually longer than strings in the English language. When messages grow in size as a result of translation to anotherlanguage, they should be allowed to wrap to subsequent lines. You should also ensure that all the access-key and shortcut-key combinations are available on international keyboards. This is because every language has a different keyboard layout, and some characters do not exist on all keyboards.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Accessibility
Accessibility:Refers to the degree of ease with which an application can be used by a variety of people. Helps people having disabilities to work with the application easily.Enables users to interact with the application more efficiently.
ASP.NET provides some guidelines that you should consider while designing your Web application to achieve high accessibility.
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Fundamentals of Designing an Accessible Application
The features of a Web application that are used frequently should have a high degree of accessibility. Therefore, a developer should strictly follow the accessibility guidelines while designing this feature. The principles that should be followed while implementing accessibility support in an application are:
Flexible user interfaceFlexible input and output featuresSimple and Intuitive
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Accessibility Design Guidelines for the Web
Some guidelines for implementing accessibility in an application are:
Standardize font stylesSupport keyboard navigationStandardize the use of imagesStandardize the use of tablesMinimize the use of style sheetsUse controls properly
Implementing Internationalization and Accessibility
3SC – Q6 Dudy Fathan Ali S.Kom
Assistive Technologies Used for Accessibility of the Web
People with disabilities use various assistive technologies for accessing a Web application. Some assistive technologies used by the people with disabilities are:
Braille and refreshable BrailleScanning softwareScreen magnifiersScreen readersVisual notifier
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Introducing the ASP.NET Security Model
The ASP.NET security model:Allows you to implement security in your Web applications. Provides restricted levels of access to secure website information from unauthorized access. Helps in maintaining data integrity and confidentiality.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Introducing the ASP.NET Security Model
The following figure displays the architecture of the ASP.NET security model.
Web Clients
ASP.NET Applications
.NET Framework
Windows Operating System
IIS
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Introducing the ASP.NET Security Model
The working of the ASP.NET security model is described in the following steps:1. Internet Information Services (IIS) receives a request from a Web
client. 2. IIS attempts to authenticate the user. 3. If ASP.NET authenticates the user, it allows requests to the specified
Web page. 4. When the ASP.NET code requests resources, the operating system
performs its own security checks to verify that the authenticated user is allowed access to the specified file and directory.
5. If access is granted, the requested resource is returned through IIS.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring IIS for Implementing Security
IIS authenticates the user who has requested for the application by using a specific type of authentication. The type of authentication depends on how the security for Web applications is configured on IIS. You need to configure security on IIS to authenticate users before they are permitted access to a Web application. IIS provides the following types of authentication to control access to your Web application:
AnonymousBasicDigestIntegrated Windows
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring an ASP.NET Application for Security
ASP.NET uses its own security mechanism to authenticate users. To be able to use ASP.NET security mechanism, you need to configure the security settings in the web.config file of the Web application. These security settings include configuring authentication, authorization, and impersonation for accessing resources in your application.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring Authentication
Authentication is the process of validating the identity of a user before granting access to a restricted resource. Authentication in a Web application can be configured by using the <authentication> element in the web.config file. The <authentication> element specifies the authentication type that is used by an application to authenticate the user. The authentication type can be specified by using the mode attribute of the <authentication> element.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring Authentication
The mode attribute can have the following values:Windows: This mode specifies that the authentication is performed by IIS by using basic, digest, or Integrated Windows authentication. Forms: This mode specifies that the user will be authenticated by using form-based authentication method.Passport: This mode specifies that the user will be authenticated by using Microsoft Passport authentication method. None: This mode specifies that no authentication mechanism is set and that any anonymous user can access the Web application.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring Impersonation
When a user requests an ASP.NET application, the request goes to IIS. IIS authenticates the user and forwards the request to ASP.NET. If ASP.NET impersonation is disabled, irrespective of the user who has logged on, the ASP.NET application will be executed by using a fixed machine-specific account. In Windows XP, this account is automatically created by ASP.NET and is named as ASPNET.
Securing Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Configuring Impersonation
Impersonation is the process of executing code under the authenticated user identity and not under the ASPNET account. Impersonation involves the following steps:1. When a request from a remote client is received, IIS carries out
authentication. If the client is authenticated, it passes the request to the ASP.NET application.
2. The application impersonates the client and uses the authentication given by IIS to access the restricted resources.
3. If authorized to access resources, the ASP.NET application returns the requested resources to the client through IIS.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Tracing in Web Applications
To ensure that the application is working properly and is not giving unexpected results, you need to keep track of the execution of your Web application.ASP.NET provides you with the tracing feature that enables you to track the program execution, thereby ensuring that your Web application runs properly. You can use tracing feature to:
View diagnostic information about a particular Web page. Display custom tracing information about the execution of an application.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Tracing in Web Applications
Tracing can be implemented at any of the following levels:
Page levelApplication level
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Tracing in Web Applications
Page-level tracing:Page-level tracing is used to generate diagnostic information at the end of page rendering. The diagnostic information includes all the information about the requests made to the page and their responses.To enable page-level tracing, you need to perform the following steps:
1. Include the following directive at the top of the page:<%@ Page Trace="True" %>
2. Include the TraceMode attribute in the @ Page directive to specify the sort order for your trace messages.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Tracing in Web Applications
The following information is displayed when page-level tracing is enabled:
Request detailsTrace informationControl treeSession stateApplication stateRequest Cookies CollectionResponse Cookies CollectionHeaders CollectionResponse Headers CollectionForm CollectionQuerystring CollectionServer Variables
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Implementing Tracing in Web Applications
Application-level tracing:Application-level tracing is used to trace information for every Web page in a Web application. A special page named trace.axd is used to view this trace information. To use the trace.axd page, you have to first enable application-level tracing within the Web.config file for your application. You can use the following attributes of the <trace> element to change the tracing settings of your website:
enabledrequestLimitpageOutputtraceModelocalOnlymostRecent
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Writing Trace Information
When a Web application is in the development stage, you often use several Response.Write statements in the program code to display debugging information, which is used to troubleshoot the application. The messages displayed using Response.Write statements are required for debugging and should not be displayed to an end user. The process of tracing enables you to insert debugging code within an application such that the debugging code does not need to be removed at the time of deployment. The Trace property of the Page class returns a Trace object, which can be used to write custom trace statements.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Writing Trace Information
The Trace object:Is an instance of the TraceContext class. Provides a set of methods and properties that help you to trace the execution of your application.
The properties of the Trace object are:IsEnabled: Denotes whether tracing is enabled for the current request.TraceMode: Sets the trace modes such as sortByCategory or sortByTime.
Some of the methods of the Trace object are:Warn: Displays the trace information in red color.Write: Displays the trace information in black color.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Using Trace Listeners
Trace listeners are used to:Collect, store, and route tracing messages. Redirect the tracing information to logs, windows, or text files.
ASP.NET provides three types of predefined trace listeners: TextWriterTraceListenerEventLogTraceListenerDefaultTraceListener
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Using Trace Listeners
Adding a trace listener:To add a trace listener in the web.config file, you need to include the following markup in the web.config file: <configuration> <system.diagnostics> <trace> <listeners> <add name="MyListener"
type="System.Diagnostics. TextWriterTraceListener"
initializeData="D:\myListener.txt" /> </listeners> </trace> </system.diagnostics></configuration>
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Using Trace Listeners
To enable ASP.NET to route tracing information to a System.Diagnostics listener, you need to include the following entry in the web.config file:<system.web>
<trace writeToDiagnosticsTrace = “true” /><customErrors mode=”off” />
</system.web>
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Using Trace Listeners
Removing a trace listener:To remove a trace listener from the listeners collection, you need to include the following markup in the web.config file:
<configuration><system.diagnostics>
<trace> <listeners> <remove name="MyListener"/> </listeners> </trace> </system.diagnostics></configuration>
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Using Trace Listeners
You can control the tracing output by using trace switches. Trace switches can be configured to provide filtered tracing output. You can also enable and disable certain tracing output using trace switches. The two types of trace switches are:
BooleanSwitch TraceSwitch
To initialize a TraceSwitch, you need to first create its object. The following code snippet shows how you can create and initialize a TraceSwitch: System.Diagnostics.TraceSwitch MyTraceSwitch = new System.Diagnostics.TraceSwitch("MySwitch", "Entire application");
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Monitoring Web Applications
After deploying a Web application, a System Administrator needs to constantly monitor the application for its proper functioning. By monitoring a Web application, you can detect the problems occurring in the application and troubleshoot them.Monitoring and troubleshooting are required to improve the performance of a Web application. To help you track monitor a Web application, ASP.NET provides you with the following two features:
Health monitoringPerformance monitoring
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Health Monitoring
ASP.NET health monitoring system:Enables you to monitor the status of the deployed Web applications. Is used to track system events and errors, which can hamper the performance of a Web application.Enables you to get the detailed run-time information about ASP.NET resources used by a Web application.Is implemented by using the System.Web.Management namespace.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Health Monitoring
You can configure applications to use built-in or customized monitoring providers. To use the health monitoring system you need to:
Configure and enable Web events to monitor.Configure and enable event providers that listen for and process various Web events.
Web events contain information about the health of a Web application.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Health Monitoring
There are several events that you can trap to monitor the health of a Web application. Some of the important events are:
WebBaseEventWebBaseErrorEventWebHeartbeatEventWebRequestEventWebErrorEventWebApplicationLifetimeEventWebRequestErrorEventWebAuditEventWebFailureAuditEvent
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Health Monitoring
The event providers are used to listen for Web events that are raised by a Web application. Some of the built-in providers are:
EventLogWebEventProviderSqlWebEventProviderSimpleMailWebEventProvider and TemplatedMailWebEventProviderTraceWebEventProviderWmiWebEventProvider
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Performance Monitoring
Performance is an important factor in making a Web application or project successful. You need to monitor a Web application to troubleshoot any performance-related issues. You need to keep a track of such errors to improve the performance of your Web application. ASP.NET provides you with several performance counters, such as Application Restarts, Requests Queued, and Errors Total to help you keep track of the execution of your Web application.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Performance Monitoring
ASP.NET supports the following two groups of performance counters:
System performance countersApplication performance counters
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Performance Monitoring
The following table lists some of the system performance counters.System Performance Counter Description
Application Running Represents the number of applications running simultaneously on a Web server.
Requests Disconnected Represents the number of requests that have been disconnected due to a communication failure.
Request Wait Time Represents the number of milliseconds that the most recent request waited in the queue for being processed by the server.
State Server Sessions Active Represents the number of user sessions that have become inactive because of some user action. This counter is available only on the computer where the state server service, aspnet_state is running.
Worker Process Running Represents the number of worker processes running on a Web server.
Tracing and Monitoring Web Applications
3SC – Q6 Dudy Fathan Ali S.Kom
Performance Monitoring
The following table lists some of the application performance counters.
Application Performance Counter Description
Anonymous Requests Represents the number of requests that are using anonymous authentication.
Anonymous Requests/Sec Represents the number of requests per second that are using anonymous authentication.
Cache Total Entries Represents the total number of entries in the cache.
Cache Total Hits Represents the total number of hits from the cache.
Debugging Requests Represents the number of requests that occur while debugging is enabled.
3SC – Q6 Dudy Fathan Ali S.Kom
Thank You!Dudy Fathan Ali S.Kom
Source : NIIT Courseware Q6M2