Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT533 Lectures Configuring, Deploying, Tracing and Error Handling.

Similar presentations


Presentation on theme: "IT533 Lectures Configuring, Deploying, Tracing and Error Handling."— Presentation transcript:

1 IT533 Lectures Configuring, Deploying, Tracing and Error Handling

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 IIS Virtual 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.asp could 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

8 Configuration Configuration 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 Root Dir Sub Dir1 Sub Dir2 web.config

9 Configuration web.config Sample web.config sample

10 Configuration Configuration 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 Configuration User-defined Settings In root web.config string customSetting = System.Configuration.ConfigurationManager.AppSettings. Get("customsetting1");  Retrieve settings at run-time

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 Tracing Methods 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 Tracing Application-Level Tracing To enable tracing across multiple pages: 1. Write web.config file in application root 2. Hit one or more pages in the application 3. Access tracing URL for the application <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false"/> http://localhost:port/WebsiteName/Trace.axd

15 Tracing Page-Level Tracing To enable tracing for a single page: 1. Add trace directive at top of page 2. Add trace calls throughout page Trace.Write(“MyApp”, “Button Clicked”); Trace.Write(“MyApp”, “Value: ” + value); 3. Access page from browser

16 Tracing Tracing 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 Handling Custom Error Pages Can specify error pages for specific HTTP status codes in web.config <customerrors mode=“remoteonly” defaultredirect=“error.htm”> <error statuscode=“404” redirect=“adminmessage.htm”/> <error statuscode=“403” redirect=“noaccessallowed.htm”/>

19 Err or Handling Custom Error Pages Can configure error pages on IIS Properties

20 Error Handling Error 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.SmtpMail class to send email to administrators


Download ppt "IT533 Lectures Configuring, Deploying, Tracing and Error Handling."

Similar presentations


Ads by Google