1 / 20

Configuring, Deploying, Tracing and Error Handling

Configuring, Deploying, Tracing and Error Handling. IT533 Lectures. IIS. Internet Information Server Microsoft’s web server http://www.iis.net/ Foundation for ASP.NET Runs in inetinfo.exe process Also FTP, NNTP, SMTP Shared resources Default location c:inetpubwwwroot

hilde
Download Presentation

Configuring, Deploying, Tracing and Error Handling

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. Configuring, Deploying, Tracing and Error Handling IT533 Lectures

  2. IIS • Internet Information Server • Microsoft’s web server • http://www.iis.net/ • Foundation for ASP.NET • Runs in inetinfo.exe process • Also FTP, NNTP, SMTP • Shared resources • Default location c:\inetpub\wwwroot • Internet Services Manager • A Microsoft Management Console (MMC) snap-in

  3. IISVirtual Directories • Provides a level of indirection from URL to actual file locations on the server • For example, the file for the url: http://myServer/myApplication/foo.aspcould be mapped to the physical location:d:\myFolder\myAppFolder\foo.asp

  4. Deployment • XCOPY deployment • Components are placed in .\bin folder • No DLL deployment, registration • Unless you’re using COM or other DLLs • No locked DLLs • DLLs are “shadow copied” into a hidden folder • .aspx files are automatically compiled • Not true for codebehind • Update code (.aspx and assemblies) while server is running • No need to stop/bounce the server

  5. Demo • Let’s take a website we’ve implemented and deloy it to our IIS server. • Look at Properties of the application:

  6. Configuration • Goal • Provide extensible configuration for admins & developers to hierarchically apply settings for an application • Solution • Store configuration data in XML text files • Format is human- and machine- readable and writable

  7. Configuration • Settings specified in configuration sections, e.g. • Security, SessionState, Compilation, CustomErrors, ProcessModel, HTTPHandlers, Globalization, AppSettings, WebServices, WebControls, etc. • Configuration information stored in web.config • It is just a file, no DLL registration, no Registry settings, no Metabase settings • <!– web.config can have comments -->

  8. Root Dir web.config Sub Dir1 Sub Dir2 ConfigurationConfiguration Hierarchy • Configuration files can be stored in application folders • Configuration system automatically detects changes • Hierarchical configuration architecture • Applies to the actual directory and all subdirectories

  9. Configurationweb.config Sample • web.config sample <configuration> <configsections> <add names=“httpmodules“ type=“System.Web.Config.HttpModulesConfigHandler“/> <add names=“sessionstate“ type=“...“/> </configsections> <httpmodules> <!--- http module subelements go here --> </httpmodules> <sessionstate> <!--- sessionstate subelements go here --> </sessionstate></configuration>

  10. ConfigurationConfiguration Hierarchy • Standard machine-wide configuration file • Provides standard set of configuration section handlers • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

  11. ConfigurationUser-defined Settings • In root web.config <appSettings> <add key="customsetting1" value="Some text here"/> </appSettings> • Retrieve settings at run-time • string customSetting = System.Configuration.ConfigurationManager.AppSettings.Get("customsetting1");

  12. Tracing • ASP.NET supports tracing • Easy way to include “debug” statements • No more messy Response.Write() calls! • Debug statements can be left in, but turned off • Great way to collect request details • Server control tree • Server variables, headers, cookies • Form/Query string parameters • Tracing provides a wealth of information about the page • Can be enabled at page- or application- level • http://msdn.microsoft.com/en-us/library/0x5wc973.aspx

  13. TracingMethods and Properties • Methods • Trace.Write: Writes category and text to trace • Trace.Warn: Writes category and text to trace in red • Properties • Trace.IsEnabled: True if tracing is turned on for the application or just that page • Trace.Mode: SortByTime, SortByCategory • Implemented in System.Web.TraceContext class

  14. TracingApplication-Level Tracing • To enable tracing across multiple pages: • Write web.config file in application root • Hit one or more pages in the application • Access tracing URL for the application • <configuration> • <system.web> • <trace enabled="true" pageOutput="false" • requestLimit="40" localOnly="false"/> • </system.web> • </configuration> http://localhost:port/WebsiteName/Trace.axd

  15. TracingPage-Level Tracing • To enable tracing for a single page: • Add trace directive at top of page • <%@ Page Trace=“True” %> • Add trace calls throughout page • Trace.Write(“MyApp”, “Button Clicked”); • Trace.Write(“MyApp”, “Value: ” + value); • Access page from browser

  16. TracingTracing Demo • Let’s add some traces to the AjaxExample website • Show information obtained from tracing

  17. Error Handling • .NET Common Language Runtime provides a unified exception architecture • Runtime errors done using exceptions • VB now supports try/catch/finally • ASP.NET also provides declarative application custom error handling • Automatically redirect users to error page when unhandled exceptions occur • Prevents ugly error messages from being sent to users

  18. Error HandlingCustom Error Pages • Can specify error pages for specific HTTP status codes in web.config • <configuration> • <customerrors mode=“remoteonly” • defaultredirect=“error.htm”> • <error statuscode=“404” • redirect=“adminmessage.htm”/> • <error statuscode=“403” • redirect=“noaccessallowed.htm”/> • </customerrors> • </configuration>

  19. Error HandlingCustom Error Pages • Can configure error pages on IIS Properties

  20. Error HandlingError Event • What do you actually do when an error occurs? • Add global.asax to your website • Use System.Diagnostics.EventLog class to write custom events to log when errors occur • Use System.Web.Mail.SmtpMailclass to send email to administrators

More Related