SlideShare a Scribd company logo
1 of 27
Developing Web Applications Using ASP.NET
Objectives


                In this session, you will learn to:
                   Describe the Page Scripting Object Model
                   Explain how to use tracing and instrumentation to monitor and
                   improve the performance of a Web application
                   Describe ASP.NET 2.0 caching techniques
                   Explain how asynchronous processing can lead to improved
                   performance for Web applications
                   Describe strategies for dealing with session state management
                   issues when deploying Web applications in a Web farm
                   environment
                   Access Page Scripting Object Model functionality
                   Implement tracing and instrumentation in Web applications
                   Implement ASP.NET 2.0 caching techniques



     Ver. 1.0                                                           Slide 1 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model


                ASP.NET is a server-side programming model.
                Client side code can be useful to respond quickly to the
                user action, if it can be completed without extra information
                from the server.
                To respond to a user action, the browser needs to post the
                page back across the Internet for processing. This slows
                down the application significantly.




     Ver. 1.0                                                         Slide 2 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                •   Client–side script can be added to an ASP.NET page by
                    using <script> tags, without the runat=“server”
                    attribute.
                •   Client-script generated by ASP.NET controls does not
                    interfere with any script added using <script> tag.
                •   You can also add client-side script to a page by using
                    server-side code.
                •   Creating client script in server code is useful when:
                       Contents of the client script depend on information that is not
                       available until run time.
                       The client script needs to be executed when the page finishes
                       loading.
                       The client script needs to be executed when users submit the
                       page.


     Ver. 1.0                                                                  Slide 3 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                An attribute added to an ASP.NET server control which is
                not defined by their classes is processed by the browser.
                This feature can be used to define client-side event
                handlers for controls.
                A server control can be referred in the client-side script by
                using its ID property as set in the server-side code.
                A server control can also be referred in the client-side script
                by setting the ClientID property of the control.




     Ver. 1.0                                                           Slide 4 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                Adding Client Scripts Dynamically:
                 • In case client-side script depends on information available only
                   at run time, it can be generated and added in the page at run
                   time by using the System.Web.UI.ClientScriptManager
                   class.
                 • To add client script to a page dynamically, you need to call one
                   of the following methods:
                       RegisterClientScriptBlock
                       RegisterClientScriptInclude
                       RegisterStartupScript
                       RegisterOnSubmitStatement




     Ver. 1.0                                                              Slide 5 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                The following code adds a script that will execute in the
                browser when the user attempts to submit a form:
                 void Page_Load ()
                 {
                   String scriptText = “return confirm(‘ Do you want
                   to submit the page?’)”;
                   ClientScript.RegisterOnSubmitStatement
                   (this.GetType(), “ConfirmSubmit”, scriptText);
                 }




     Ver. 1.0                                                               Slide 6 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                Client Callbacks Without Postbacks:
                   Client callbacks provide a way to obtain information from the
                   server without executing the entire page again.
                   In a client callback, client-side code on the page invokes a
                   server-side method without performing a postback. This
                   method can return results back to the client-side script.
                   An ASP.NET page that implements client callback must:
                      Implement the ICallbackEventHandler interface.
                      Include a method that implements the RaiseCallbackEvent
                      method from the interface.
                      Contain the following client script functions:
                         A helper method that performs the callback
                         A method that receives the callback from the server code
                         A method that calls the helper method




     Ver. 1.0                                                                       Slide 7 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                Implementing the ICallbackEventHandler Interface:
                   A page can implement the ICallbackEventHandler
                   interface by defining the class for the page as:
                      public partial class CallBack_class:
                      System.Web.UI.ICallbackEventHandler
                Implementing the RaiseCallbackEvent Method:
                   The following is a sample implementation of the
                   RaiseCallbackEvent method of the
                   ICallbackEventHandler interface:
                     public string RaiseCallbackEvent (string
                     eventArgument)
                     {
                       Return eventArgument + “ new value”;
                     }


     Ver. 1.0                                                     Slide 8 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                Sending the Callback:
                   The following example shows how to dynamically create a
                   function that invokes the callback:
                    void Page_Load(object sender, EventArgs e)
                    {
                      string cbReference =
                      Page.ClientScript.GetCallbackEventReference(
                      this, “arg”, “ReceiveServerData”,
                      “context”);
                      string callbackScript = “function
                      CallTheServer(arg, context) {“ + cbReference
                      + “; }”;

                        Page.ClientScript.RegisterClientScriptBlock(
                        this.GetType(), “CallTheServer”,
                        callbackScript, true);
     Ver. 1.0
                    }                                              Slide 9 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                The following example shows how an HTML input button
                control can initiate the callback process:
                 <input type=“button” id=“MyButton”
                     onclick=“return CallTheServer(‘Some
                     Data’);” />




     Ver. 1.0                                                     Slide 10 of 27
Developing Web Applications Using ASP.NET
The Page Scripting Object Model (Contd.)


                Receiving the Callback:
                   The following example shows how to create a client-side
                   method for receiving a callback:
                    <script type=“text/javascript”>
                    function ReceiveServerData(rvalue, context)
                    {
                         span1.innerText = “Return value = “ +
                            rvalue;
                    }
                    </script>




     Ver. 1.0                                                        Slide 11 of 27
Developing Web Applications Using ASP.NET
Tracing and Instrumentation in Web Applications


                •   Tracing features enable gathering of information for
                    debugging and performance tuning.
                •   Tracing can be enabled for an ASP.NET page by adding
                    trace=“true” attribute to the <%@page%> directive.
                •   Diagnostic information, mostly related to the performance of
                    the application is generated and displayed at the bottom of
                    the rendered page.
                •   Custom instrumentation data can be added to the trace
                    information displayed by calling methods on the
                    System.Web.TraceContext class.
                •   In addition to displaying messages that you send, trace
                    information includes the times at which the messages were
                    received. This can be used to diagnose parts of the code
                    that execute slowly.

     Ver. 1.0                                                           Slide 12 of 27
Developing Web Applications Using ASP.NET
Tracing and Instrumentation in Web Applications (Contd.)


                • The classes in the System.Diagnostics namespace
                  allow you to implement a tracing system.
                • Trace statements must be added at strategic points within
                  the code to generate tracing information.
                • Trace Listener objects receive tracing output and write it to
                  logs, text files, or the screen.
                • ASP.NET tracing information can also be sent to a
                  System.Diagnostic listener by using Web.config file:
                    <system.web>
                      <trace writeToDiagnosticsTrace=“true”/>
                       <CustomErrors mode=“off”/>
                    </system.web>




     Ver. 1.0                                                           Slide 13 of 27
Developing Web Applications Using ASP.NET
Tracing and Instrumentation in Web Applications (Contd.)


                •   The System.Diagnostics tracing information can be
                    routed to the browser by the using Web.config file:
                    <system.diagnostics>
                      <trace>
                        <listeners>
                          <add name = “WebPageTraceListener”
                              type=“System.Web.WebPageTraceListener,
                              System.Web,
                              Version =2.0.3600.0,
                              Culture=neutral,
                              PublicKeyToken=b03f5f7f11d50a3a”/>
                        </listeners>
                      </trace>
                    </system.diagnostics>

     Ver. 1.0                                                       Slide 14 of 27
Developing Web Applications Using ASP.NET
ASP.NET 2.0 Caching Techniques


                •   Objects and pages that require substantial resources can
                    be cached for reuse.
                •   The application cache enables caching of objects and data
                    for reuse.
                •   Storing data in the application cache is similar to storing
                    data in the Application object.
                •   Objects in the cache are volatile and can be removed
                    without warning.
                •   Another type of cache, the Page Output cache stores
                    rendered pages in server memory.
                •   You can enable Page Output caching by including the
                    <$@ OutputCache %> directive on the page:
                    <%@ OutputCache Duration=“60”
                    VaryByParam=“None”%>

     Ver. 1.0                                                           Slide 15 of 27
Developing Web Applications Using ASP.NET
ASP.NET 2.0 Caching Techniques (Contd.)


                •   In some cases, it is not feasible to cache the entire page.
                •   A page can be cached partially by:
                     • Adding <%@OutputCache%> directive in the control that needs
                       to be cached.
                     • Placing <%@OutputCache%> directive on the page and
                       marking certain sections exempt from caching by surrounding
                       these sections with a Substitution control.
                •   Multiple versions of a page can be cached by using
                    varybyparam attribute in the <%@OutputCache%>
                    directive:
                     <%@OutputCache Duration = “60” VaryByParam=“City”%>




     Ver. 1.0                                                             Slide 16 of 27
Developing Web Applications Using ASP.NET
Asynchronous Processing in Web Applications


                •   A Web page can be configured to execute some requests
                    asynchronously.
                •   On a Web page, it can be specified that runtime should not
                    necessarily wait for a long method to complete before
                    continuing with the next piece of code.
                •   The Async property of the Page object is used to enable
                    code on a Web page to run asynchronously:
                     <%@ page Async=“true”%>
                    To perform an asynchronous operation, the following
                    methods need to be registered:
                     • Begin: This method sets the operation running.
                     • End: This method responds when the operation has
                       completed.



     Ver. 1.0                                                             Slide 17 of 27
Developing Web Applications Using ASP.NET
Asynchronous Processing in Web Applications (Contd.)


                Calling Web Services Asynchronously:
                   Web services can be hosted on servers remote from the one
                   that hosts the Web application.
                   Web services can be called asynchronously in case other
                   operations do not depend on their result.
                   There are two ways to call a Web service asynchronously:
                      By using a callback
                      By using a WaitHandle
                Loading XML Asynchronously:
                   XML files can be large and located remotely from the Web
                   server. As a result, they may take a long time to load.
                   XML files can be loaded asynchronously in the same way as a
                   Web service.




     Ver. 1.0                                                         Slide 18 of 27
Developing Web Applications Using ASP.NET
ASP.NET Performance Counters


               Are used to capture performance data and log them in the
               Performance Logging database or Windows Performance
               monitor.
               ASP.NET supports the following types of performance
               counters:
                  System: Are exposed in the Windows Performance monitor as
                  the ASP.NET performance counter object.
                  Application: Are exposed as the ASP.NET Applications
                  performance object.
               The following are some of the performance counters:
                  Anonymous Requests
                  Transactions Pending
                  Requests Timed Out



    Ver. 1.0                                                        Slide 19 of 27
Developing Web Applications Using ASP.NET
Web Farm Development Considerations


               Response time of a Web application can be reduced by
               hosting it on a Web farm.
               A Web farm is group of servers configured to act as a single
               Web server.
               The servers in a Web farm can share the processing
               between them.
               You should consider using a Web farm if you have
               optimized your application fully and upgraded your server
               as much as possible but the application is still not
               responding quickly.




    Ver. 1.0                                                       Slide 20 of 27
Developing Web Applications Using ASP.NET
Web Farm Development Considerations (Contd.)


                Considerations for Building a Web Farm:
                   Using an External Session State Provider:
                      In a Web farm each request in a session can be directed to different
                      servers in the farm. Therefore, it is not practical to store session
                      state in memory of any of the servers.
                      Two external session state providers can be used:
                          The ASP.NET State Service
                          Microsoft SQL Server
                   Configuring the <MachineKey> tag in machine.config:
                    • The <machineKey> tag configures the way encryption is used to
                      protect forms authentication cookies and view state information.
                    • Encryption keys are generated automatically and are unique to
                      each server.
                    • To access shared protected information in a Web farm, each server
                      must use the same encryption keys.



     Ver. 1.0                                                                  Slide 21 of 27
Developing Web Applications Using ASP.NET
Web Farm Development Considerations (Contd.)


                Deploying to a Web Farm:
                   Each server in a Web farm must have an identical copy of the
                   application.
                   Microsoft Windows Installer package is helpful to ensure
                   consistency among different servers while deploying the
                   application.




     Ver. 1.0                                                           Slide 22 of 27
Developing Web Applications Using ASP.NET
Demo: Optimizing Web Application Performance


                Problem Statement:
                   You are a developer in the Adventure Works organization, a
                   fictitious bicycle manufacturer You have been asked to assist
                   in creating a new Business-to-Consumer (B2C) Web
                   application and a related Business-to-Employee (B2E) extranet
                   portal.
                   Decisions on the design of the application have already been
                   made. You have been asked to carry out a number of specific
                   tasks in order to implement various elements of this design. As
                   part of the first phase of the B2C development, you have been
                   asked to prototype various performance related techniques for
                   the Web application.




     Ver. 1.0                                                            Slide 23 of 27
Developing Web Applications Using ASP.NET
Demo: Optimizing Web Application Performance (Contd.)


                Solution:
                 • You need to perform following tasks:
                    1. Access the Page Scripting Object Model
                        • Open the starter solution.
                        • Write the test code to set the focus to the Name text box when
                          displaying the Online Survey page.
                        • Use the ClientScript object to inject client-side script that displays
                          a message box onto the Web page.
                        • Use the ClientScript object to implement out-of-band callbacks.
                        • Add a client-side JavaScript function for receiving the result of the
                          callback.
                        • Test the callbacks.




     Ver. 1.0                                                                         Slide 24 of 27
Developing Web Applications Using ASP.NET
Demo: Optimizing Web Application Performance (Contd.)


                1. Implement ASP.NET Caching Techniques
                    • Implement page caching declaratively.
                    • Implement parameterized page caching in code.
                    • Prevent portions of a page from being cached by using a
                      Substitution control.
                    • Implement Web page fragment caching by using a Web user control.
                2. Implement Tracing and Instrumentation Techniques in Web
                   Applications
                    a.   Add and review tracing information on a Web page.
                    b.   Add event logging capabilities to the Web application.
                    c.   Add and manipulate performance counters for the Web application.
                    d.   Test the logging and performance counter management of the Web
                         application.




     Ver. 1.0                                                                     Slide 25 of 27
Developing Web Applications Using ASP.NET
Summary


               In this session, you learned that:
                • Client-side script can be added to an ASP.NET page by using
                  <script> tags, without the runat=“server” attribute.
                • System.Web.UI.ClientScriptManager class is used to
                  generate and render client-side code at run time.
                • To enable tracing for an ASP.NET page trace=“true”
                  attribute can be added to the <%@Page%> directive.
                • The classes in the System.Diagnostics namespace also
                  provides a tracing system.
                • The ASP.NET application cache enables the storing of objects
                  and data for reuse.
                • A page can be cached by including the <%@OutputCache%>
                  directive on the page.




    Ver. 1.0                                                          Slide 26 of 27
Developing Web Applications Using ASP.NET
Summary (Contd.)


               • The Async property of the Page object enables code on the
                 Web page to run asynchronously.
               • Response time of a Web application can be improved by
                 hosting it on a Web farm.
               • The ASP.NET State Service or Microsoft SQL Server can be
                 used as an external session state provider in a Web farm.




    Ver. 1.0                                                        Slide 27 of 27

More Related Content

What's hot

Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web applicationRahul Bansal
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Niit Care
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer home
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.netSHADAB ALI
 
Chapter6 web apps-tomcat
Chapter6 web apps-tomcatChapter6 web apps-tomcat
Chapter6 web apps-tomcatVenkat Gowda
 
Php apache vs iis By Hafedh Yahmadi
Php apache vs iis  By Hafedh YahmadiPhp apache vs iis  By Hafedh Yahmadi
Php apache vs iis By Hafedh YahmadiTechdaysTunisia
 
Installing web sphere application server v7 on red hat enterprise linux v6.3
Installing web sphere application server v7 on red hat enterprise linux v6.3Installing web sphere application server v7 on red hat enterprise linux v6.3
Installing web sphere application server v7 on red hat enterprise linux v6.3Dave Hay
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...Mark Leusink
 
PHP konferencija - Microsoft
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoftnusmas
 
Difference between ajax and silverlight
Difference between ajax and silverlightDifference between ajax and silverlight
Difference between ajax and silverlightUmar Ali
 
Know, Share, Do - Custom Apps
Know, Share, Do - Custom AppsKnow, Share, Do - Custom Apps
Know, Share, Do - Custom AppsTIMETOACT GROUP
 
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformWordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformGeorge Kanellopoulos
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebGeorge Kanellopoulos
 

What's hot (20)

Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Asp net
Asp netAsp net
Asp net
 
Asp.net
Asp.netAsp.net
Asp.net
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Chapter6 web apps-tomcat
Chapter6 web apps-tomcatChapter6 web apps-tomcat
Chapter6 web apps-tomcat
 
Php apache vs iis By Hafedh Yahmadi
Php apache vs iis  By Hafedh YahmadiPhp apache vs iis  By Hafedh Yahmadi
Php apache vs iis By Hafedh Yahmadi
 
Installing web sphere application server v7 on red hat enterprise linux v6.3
Installing web sphere application server v7 on red hat enterprise linux v6.3Installing web sphere application server v7 on red hat enterprise linux v6.3
Installing web sphere application server v7 on red hat enterprise linux v6.3
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
PHP konferencija - Microsoft
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoft
 
Difference between ajax and silverlight
Difference between ajax and silverlightDifference between ajax and silverlight
Difference between ajax and silverlight
 
Know, Share, Do - Custom Apps
Know, Share, Do - Custom AppsKnow, Share, Do - Custom Apps
Know, Share, Do - Custom Apps
 
Assignment3.2
Assignment3.2Assignment3.2
Assignment3.2
 
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformWordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
 
Microsoft Tech Ed 2006 #1
Microsoft Tech Ed 2006 #1Microsoft Tech Ed 2006 #1
Microsoft Tech Ed 2006 #1
 
Asp.net
 Asp.net Asp.net
Asp.net
 
Microsoft Tech Ed 2006 #2
Microsoft Tech Ed 2006 #2Microsoft Tech Ed 2006 #2
Microsoft Tech Ed 2006 #2
 
Asp net
Asp netAsp net
Asp net
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The Nextweb
 

Similar to 13 asp.net session19

13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Mani Chaubey
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Vivek chan
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Vivek chan
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointRob Windsor
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Mani Chaubey
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Vivek chan
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Niit Care
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 
Overview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company indiaOverview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company indiaJignesh Aakoliya
 
ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916Viral Patel
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008Caleb Jenkins
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controlsRaed Aldahdooh
 

Similar to 13 asp.net session19 (20)

13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
 
RIA / SPA with ASP.NET
RIA / SPA with ASP.NETRIA / SPA with ASP.NET
RIA / SPA with ASP.NET
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Overview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company indiaOverview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company india
 
ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 

Recently uploaded (20)

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 

13 asp.net session19

  • 1. Developing Web Applications Using ASP.NET Objectives In this session, you will learn to: Describe the Page Scripting Object Model Explain how to use tracing and instrumentation to monitor and improve the performance of a Web application Describe ASP.NET 2.0 caching techniques Explain how asynchronous processing can lead to improved performance for Web applications Describe strategies for dealing with session state management issues when deploying Web applications in a Web farm environment Access Page Scripting Object Model functionality Implement tracing and instrumentation in Web applications Implement ASP.NET 2.0 caching techniques Ver. 1.0 Slide 1 of 27
  • 2. Developing Web Applications Using ASP.NET The Page Scripting Object Model ASP.NET is a server-side programming model. Client side code can be useful to respond quickly to the user action, if it can be completed without extra information from the server. To respond to a user action, the browser needs to post the page back across the Internet for processing. This slows down the application significantly. Ver. 1.0 Slide 2 of 27
  • 3. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) • Client–side script can be added to an ASP.NET page by using <script> tags, without the runat=“server” attribute. • Client-script generated by ASP.NET controls does not interfere with any script added using <script> tag. • You can also add client-side script to a page by using server-side code. • Creating client script in server code is useful when: Contents of the client script depend on information that is not available until run time. The client script needs to be executed when the page finishes loading. The client script needs to be executed when users submit the page. Ver. 1.0 Slide 3 of 27
  • 4. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) An attribute added to an ASP.NET server control which is not defined by their classes is processed by the browser. This feature can be used to define client-side event handlers for controls. A server control can be referred in the client-side script by using its ID property as set in the server-side code. A server control can also be referred in the client-side script by setting the ClientID property of the control. Ver. 1.0 Slide 4 of 27
  • 5. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) Adding Client Scripts Dynamically: • In case client-side script depends on information available only at run time, it can be generated and added in the page at run time by using the System.Web.UI.ClientScriptManager class. • To add client script to a page dynamically, you need to call one of the following methods: RegisterClientScriptBlock RegisterClientScriptInclude RegisterStartupScript RegisterOnSubmitStatement Ver. 1.0 Slide 5 of 27
  • 6. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) The following code adds a script that will execute in the browser when the user attempts to submit a form: void Page_Load () { String scriptText = “return confirm(‘ Do you want to submit the page?’)”; ClientScript.RegisterOnSubmitStatement (this.GetType(), “ConfirmSubmit”, scriptText); } Ver. 1.0 Slide 6 of 27
  • 7. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) Client Callbacks Without Postbacks: Client callbacks provide a way to obtain information from the server without executing the entire page again. In a client callback, client-side code on the page invokes a server-side method without performing a postback. This method can return results back to the client-side script. An ASP.NET page that implements client callback must: Implement the ICallbackEventHandler interface. Include a method that implements the RaiseCallbackEvent method from the interface. Contain the following client script functions: A helper method that performs the callback A method that receives the callback from the server code A method that calls the helper method Ver. 1.0 Slide 7 of 27
  • 8. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) Implementing the ICallbackEventHandler Interface: A page can implement the ICallbackEventHandler interface by defining the class for the page as: public partial class CallBack_class: System.Web.UI.ICallbackEventHandler Implementing the RaiseCallbackEvent Method: The following is a sample implementation of the RaiseCallbackEvent method of the ICallbackEventHandler interface: public string RaiseCallbackEvent (string eventArgument) { Return eventArgument + “ new value”; } Ver. 1.0 Slide 8 of 27
  • 9. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) Sending the Callback: The following example shows how to dynamically create a function that invokes the callback: void Page_Load(object sender, EventArgs e) { string cbReference = Page.ClientScript.GetCallbackEventReference( this, “arg”, “ReceiveServerData”, “context”); string callbackScript = “function CallTheServer(arg, context) {“ + cbReference + “; }”; Page.ClientScript.RegisterClientScriptBlock( this.GetType(), “CallTheServer”, callbackScript, true); Ver. 1.0 } Slide 9 of 27
  • 10. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) The following example shows how an HTML input button control can initiate the callback process: <input type=“button” id=“MyButton” onclick=“return CallTheServer(‘Some Data’);” /> Ver. 1.0 Slide 10 of 27
  • 11. Developing Web Applications Using ASP.NET The Page Scripting Object Model (Contd.) Receiving the Callback: The following example shows how to create a client-side method for receiving a callback: <script type=“text/javascript”> function ReceiveServerData(rvalue, context) { span1.innerText = “Return value = “ + rvalue; } </script> Ver. 1.0 Slide 11 of 27
  • 12. Developing Web Applications Using ASP.NET Tracing and Instrumentation in Web Applications • Tracing features enable gathering of information for debugging and performance tuning. • Tracing can be enabled for an ASP.NET page by adding trace=“true” attribute to the <%@page%> directive. • Diagnostic information, mostly related to the performance of the application is generated and displayed at the bottom of the rendered page. • Custom instrumentation data can be added to the trace information displayed by calling methods on the System.Web.TraceContext class. • In addition to displaying messages that you send, trace information includes the times at which the messages were received. This can be used to diagnose parts of the code that execute slowly. Ver. 1.0 Slide 12 of 27
  • 13. Developing Web Applications Using ASP.NET Tracing and Instrumentation in Web Applications (Contd.) • The classes in the System.Diagnostics namespace allow you to implement a tracing system. • Trace statements must be added at strategic points within the code to generate tracing information. • Trace Listener objects receive tracing output and write it to logs, text files, or the screen. • ASP.NET tracing information can also be sent to a System.Diagnostic listener by using Web.config file: <system.web> <trace writeToDiagnosticsTrace=“true”/> <CustomErrors mode=“off”/> </system.web> Ver. 1.0 Slide 13 of 27
  • 14. Developing Web Applications Using ASP.NET Tracing and Instrumentation in Web Applications (Contd.) • The System.Diagnostics tracing information can be routed to the browser by the using Web.config file: <system.diagnostics> <trace> <listeners> <add name = “WebPageTraceListener” type=“System.Web.WebPageTraceListener, System.Web, Version =2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”/> </listeners> </trace> </system.diagnostics> Ver. 1.0 Slide 14 of 27
  • 15. Developing Web Applications Using ASP.NET ASP.NET 2.0 Caching Techniques • Objects and pages that require substantial resources can be cached for reuse. • The application cache enables caching of objects and data for reuse. • Storing data in the application cache is similar to storing data in the Application object. • Objects in the cache are volatile and can be removed without warning. • Another type of cache, the Page Output cache stores rendered pages in server memory. • You can enable Page Output caching by including the <$@ OutputCache %> directive on the page: <%@ OutputCache Duration=“60” VaryByParam=“None”%> Ver. 1.0 Slide 15 of 27
  • 16. Developing Web Applications Using ASP.NET ASP.NET 2.0 Caching Techniques (Contd.) • In some cases, it is not feasible to cache the entire page. • A page can be cached partially by: • Adding <%@OutputCache%> directive in the control that needs to be cached. • Placing <%@OutputCache%> directive on the page and marking certain sections exempt from caching by surrounding these sections with a Substitution control. • Multiple versions of a page can be cached by using varybyparam attribute in the <%@OutputCache%> directive: <%@OutputCache Duration = “60” VaryByParam=“City”%> Ver. 1.0 Slide 16 of 27
  • 17. Developing Web Applications Using ASP.NET Asynchronous Processing in Web Applications • A Web page can be configured to execute some requests asynchronously. • On a Web page, it can be specified that runtime should not necessarily wait for a long method to complete before continuing with the next piece of code. • The Async property of the Page object is used to enable code on a Web page to run asynchronously: <%@ page Async=“true”%> To perform an asynchronous operation, the following methods need to be registered: • Begin: This method sets the operation running. • End: This method responds when the operation has completed. Ver. 1.0 Slide 17 of 27
  • 18. Developing Web Applications Using ASP.NET Asynchronous Processing in Web Applications (Contd.) Calling Web Services Asynchronously: Web services can be hosted on servers remote from the one that hosts the Web application. Web services can be called asynchronously in case other operations do not depend on their result. There are two ways to call a Web service asynchronously: By using a callback By using a WaitHandle Loading XML Asynchronously: XML files can be large and located remotely from the Web server. As a result, they may take a long time to load. XML files can be loaded asynchronously in the same way as a Web service. Ver. 1.0 Slide 18 of 27
  • 19. Developing Web Applications Using ASP.NET ASP.NET Performance Counters Are used to capture performance data and log them in the Performance Logging database or Windows Performance monitor. ASP.NET supports the following types of performance counters: System: Are exposed in the Windows Performance monitor as the ASP.NET performance counter object. Application: Are exposed as the ASP.NET Applications performance object. The following are some of the performance counters: Anonymous Requests Transactions Pending Requests Timed Out Ver. 1.0 Slide 19 of 27
  • 20. Developing Web Applications Using ASP.NET Web Farm Development Considerations Response time of a Web application can be reduced by hosting it on a Web farm. A Web farm is group of servers configured to act as a single Web server. The servers in a Web farm can share the processing between them. You should consider using a Web farm if you have optimized your application fully and upgraded your server as much as possible but the application is still not responding quickly. Ver. 1.0 Slide 20 of 27
  • 21. Developing Web Applications Using ASP.NET Web Farm Development Considerations (Contd.) Considerations for Building a Web Farm: Using an External Session State Provider: In a Web farm each request in a session can be directed to different servers in the farm. Therefore, it is not practical to store session state in memory of any of the servers. Two external session state providers can be used: The ASP.NET State Service Microsoft SQL Server Configuring the <MachineKey> tag in machine.config: • The <machineKey> tag configures the way encryption is used to protect forms authentication cookies and view state information. • Encryption keys are generated automatically and are unique to each server. • To access shared protected information in a Web farm, each server must use the same encryption keys. Ver. 1.0 Slide 21 of 27
  • 22. Developing Web Applications Using ASP.NET Web Farm Development Considerations (Contd.) Deploying to a Web Farm: Each server in a Web farm must have an identical copy of the application. Microsoft Windows Installer package is helpful to ensure consistency among different servers while deploying the application. Ver. 1.0 Slide 22 of 27
  • 23. Developing Web Applications Using ASP.NET Demo: Optimizing Web Application Performance Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer You have been asked to assist in creating a new Business-to-Consumer (B2C) Web application and a related Business-to-Employee (B2E) extranet portal. Decisions on the design of the application have already been made. You have been asked to carry out a number of specific tasks in order to implement various elements of this design. As part of the first phase of the B2C development, you have been asked to prototype various performance related techniques for the Web application. Ver. 1.0 Slide 23 of 27
  • 24. Developing Web Applications Using ASP.NET Demo: Optimizing Web Application Performance (Contd.) Solution: • You need to perform following tasks: 1. Access the Page Scripting Object Model • Open the starter solution. • Write the test code to set the focus to the Name text box when displaying the Online Survey page. • Use the ClientScript object to inject client-side script that displays a message box onto the Web page. • Use the ClientScript object to implement out-of-band callbacks. • Add a client-side JavaScript function for receiving the result of the callback. • Test the callbacks. Ver. 1.0 Slide 24 of 27
  • 25. Developing Web Applications Using ASP.NET Demo: Optimizing Web Application Performance (Contd.) 1. Implement ASP.NET Caching Techniques • Implement page caching declaratively. • Implement parameterized page caching in code. • Prevent portions of a page from being cached by using a Substitution control. • Implement Web page fragment caching by using a Web user control. 2. Implement Tracing and Instrumentation Techniques in Web Applications a. Add and review tracing information on a Web page. b. Add event logging capabilities to the Web application. c. Add and manipulate performance counters for the Web application. d. Test the logging and performance counter management of the Web application. Ver. 1.0 Slide 25 of 27
  • 26. Developing Web Applications Using ASP.NET Summary In this session, you learned that: • Client-side script can be added to an ASP.NET page by using <script> tags, without the runat=“server” attribute. • System.Web.UI.ClientScriptManager class is used to generate and render client-side code at run time. • To enable tracing for an ASP.NET page trace=“true” attribute can be added to the <%@Page%> directive. • The classes in the System.Diagnostics namespace also provides a tracing system. • The ASP.NET application cache enables the storing of objects and data for reuse. • A page can be cached by including the <%@OutputCache%> directive on the page. Ver. 1.0 Slide 26 of 27
  • 27. Developing Web Applications Using ASP.NET Summary (Contd.) • The Async property of the Page object enables code on the Web page to run asynchronously. • Response time of a Web application can be improved by hosting it on a Web farm. • The ASP.NET State Service or Microsoft SQL Server can be used as an external session state provider in a Web farm. Ver. 1.0 Slide 27 of 27