1 / 33

Module 15: Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application

Module 15: Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application. Overview. Using the Cache Object Using ASP.NET Output Caching Configuring an ASP.NET Web Application Deploying an ASP.NET Web Application. Lesson: Using the Cache Object. What Is the Cache Object?

jack
Download Presentation

Module 15: Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module 15:Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application

  2. Overview • Using the Cache Object • Using ASP.NET Output Caching • Configuring an ASP.NET Web Application • Deploying an ASP.NET Web Application

  3. Lesson: Using the Cache Object • What Is the Cache Object? • Advantages of Using the Cache Object • How to Use the Cache Object • Removing Items from the Cache Object • Demonstration: Using the Cache Object

  4. What Is the Cache Object? • An object used to store information • One Cache object per Web Application • An alternative to application variables • Not used to store information in session variables • Uses key-value pairs to store and retrieve items Cache("myKey") = myValue Cache["myKey"] = myValue;

  5. Advantages of Using the Cache Object • Faster than creating a new object for each request • Supports internal locking • Automatic cache resource management • Supports callback functions • Supports removal based on dependencies

  6. How to Use the Cache Object • Writing to the Cache object: • Retrieving values from the Cache object: 'Implicit method Cache("myKey") = myValue 'Explicit method Cache.Insert("myKey", myValue, Dependency, AbsoluteExpiration, _ SlidingExpiration, CacheItemPriority, CacheItemRemovedCallBack) //Implicit method Cache["myKey"] = myValue; //Explicit method Cache.Insert("myKey", myValue, Dependency, AbsoluteExpiration, SlidingExpiration, CacheItemPriority, CacheItemRemovedCallBack); myValue = Cache("myKey") myValue = Cache["myKey"];

  7. Removing Items from the Cache Object • AbsoluteExpiration time • SlidingExpiration time • Dependent on a changed value • Cache item priority DateTime.Now.AddMinutes(5) TimeSpan.FromSeconds(20) AddCacheItemDependency("Variable.Value") CacheItemPriority.High

  8. Demonstration: Using the Cache Object • Run the CacheTest.aspx page without the Cache object enabled • Run the CacheTest.aspx page with the Cache object enabled • Run the CacheTest.aspx page with the Cache object enabled and with a dependency

  9. Lesson: Using ASP.NET Output Caching • Multimedia: Output Caching • Output Cache Types • How to Use Page Output Caches • Demonstration: Page Output Caching • How to Use Fragment Caching

  10. Multimedia: Output Caching

  11. Output Cache Types • Page caching • Page fragment caching as a user control • XML Web service caching

  12. How to Use Page Output Caches • Cache content is generated from dynamic pages • Entire Web page is available in cache • Set cache duration in seconds • Set the VaryByParam property to control the number of page variations in the cache <%@ OutputCache Duration="900" VaryByParam="none" %>

  13. Demonstration: Page Output Caching • Show how a page that does not cache changes with each refresh • Show how a page that caches does not change with each refresh • Show how changing a parameter can cause a new page to be cached

  14. How to Use Fragment Caching • Convert the page fragment into a user control • Set the Duration and varyByParam properties <%@ OutputCache Duration="120" VaryByParam="none" %>

  15. Lesson: Configuring an ASP.NET Web Application • Overview of Configuration Methods • Configuring a Web Server Using Machine.config • Configuring an Application Using Web.config • Understanding Configuration Inheritance • Demonstration: Configuration Inheritance • Practice: Determining Configuration Inheritance • Storing and Retrieving Data in Web.config • Using Dynamic Properties • Demonstration: Using Dynamic Properties

  16. Overview of Configuration Methods • Machine.config file • Machine-level settings • Web.config files • Application and directory-level settings • Both Machine.config and Web.config files are: • Well-formed XML • camelCase • Extendable

  17. Configuring a Web Server Using Machine.config • Settings in the Machine.config file affect all Web applications on the server • Only one Machine.config file per Web server • Most settings can be overridden at the application level using Web.config files

  18. Configuring an Application Using Web.config • One or more Web.config files per Web application • All configuration information for the application is contained in the Web.config files • Contains a section for each major category of ASP.NET functionality • Security • Mode • General application settings • Tracing

  19. Understanding Configuration Inheritance • Application-level Web.config file inherits settings from Machine.config file • Settings in Web.config file that conflict override inherited settings • Individual directories may have Web.config files that inherit from—and can override—application-level settings CONFIG Machine.config VirtualDir Web.config SubDir Web.config

  20. Demonstration: Configuration Inheritance • Create a subfolder that contains a Web.config file • Show differences between the main Web.config file and the subfolder's Web.config file • Demonstrate how the Web Form reads information from the Web.config files • Delete the Web.config file from the subfolder and refresh the Web Form

  21. Practice: Determining Configuration Inheritance • Students will: • Determine the configuration settings for a Web application based on several variables • Time: 5 Minutes

  22. Storing and Retrieving Data in Web.config • Storing application settings in a Web.config file • Retrieving application settings from a Web.config file <configuration> <appSettings> <add key="pubs" value="server=localhost; integrated security=true; database=pubs"/> </appSettings> </configuration> Dim strPubs As String = _ ConfigurationSettings.AppSettings("pubs") AppSettingsReader App = new AppSettingsReader(); string strPubs = (string)App.GetValue("pubs", typeof(string));

  23. Using Dynamic Properties • Store property values in Web.config files rather than in the application's compiled code • Allows easy updates without recompiling the application • Enable and configure through object properties

  24. Demonstration: Using Dynamic Properties • Configure a SqlConnection object to use dynamic properties • Show the newly generated code in the code-behind page • Open Web.config file and show the SqlConnection1.ConnectionString key in the appSettings section

  25. Lesson: Deploying an ASP.NET Web Application • Web Application Deployment • Preparing a Web Application for Deployment • Practice: Selecting Necessary Files • Sharing Assemblies in the Global Assembly Cache • Updating Your Web Application

  26. Web Application Deployment • Copy files locally or FTP files remotely • Configure the target folder as a virtual directory in IIS • Copy all necessary files, including the \bin directory and content • No need to register components

  27. Preparing a Web Application for Deployment • Build the Web application • Do not select unnecessary files • Visual Studio .NET solution files (.vbproj, .vbproj.webinfo, .csproj, .csproj.webinfo, etc.) • Resource (.resx) files • Code-behind pages (.vb, .cs) • Copy or FTP necessary files to the production directory

  28. Practice: Selecting Necessary Files • Students will: • Select the files necessary for a deployment • Time: 5 Minutes

  29. Sharing Assemblies in the Global Assembly Cache • The global assembly cache provides storage for assemblies you need to share • Machine-wide cache for code • Because DLL files are not registered, they are not easily shared between Web applications

  30. Updating Your Web Application • Copy or FTP files to update the Web application • Do not need to stop and restart IIS • .dll files can be updated while the site is still running • Output cache protects existing users

  31. Review • Using the Cache Object • Using ASP.NET Output Caching • Configuring an ASP.NET Web Application • Deploying an ASP.NET Web Application

  32. Lab 15: Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application Logon Page Login.aspx BenefitsHome PageDefault.aspx CohoWinery Page HeaderHeader.ascx ASPState Menu ComponentClass1.vb or Class1.cs Registration Register.aspx Web.config tempdb Life InsuranceLife.aspx RetirementRetirement.aspx MedicalMedical.aspx DentalDental.aspx XML Web ServicedentalService1.asmx ProspectusProspectus.aspx DoctorsDoctors.aspx User Controlnamedate.ascx Lab Web Application XML Files Doctors Dentists

  33. Course Evaluation

More Related