Introduction to ASP.NET, Second Edition2 Chapter Objectives.

Slides:



Advertisements
Similar presentations
BIM313 – Advanced Programming Techniques Debugging 1.
Advertisements

Working with ASP Pages. Slide 2 The Tag (1) Remember that most ASP.NET pages contain a single tag with the runat attribute set It’s possible to have multiple.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
1 Chapter 12 Working With Access 2000 on the Internet.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Introduction to ASP.NET
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Chapter 12: Advanced Topics: Exception Handling Visual Basic.NET Programming: From Problem Analysis to Program Design.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
JavaScript, Fourth Edition
ASP.NET Programming with C# and SQL Server First Edition
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Creating a Console Application with Visual Studio
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
A First Program Using C#
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Microsoft ASP.NET: An Overview of Caching Holly Mazerolle Developer Support Engineer Microsoft Developer Support Microsoft Corporation.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Tracing, Logging, and Error Handling MacDonald Ch. 8 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
ASP.NET Programming with C# and SQL Server First Edition Chapter 6 Debugging and Error Handling.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
ASP The Global.asa file Y.-H. Chen International College Ming-Chuan University Fall, 2004.
ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Introduction to Exception Handling and Defensive Programming.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
Lecture Note 8: ASP Including Files and The Global.asa file.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
11 Getting Started with ASP.NET Beginning ASP.NET in C# and VB Chapters 1 and 2.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 Introducing Web Developer Tools Rapid application development tools ASP.NET-compatible web editors –Visual Studio.NET Professional Edition –Visual Studio.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
ASP.NET Programming with C# and SQL Server First Edition
Session Variables and Post Back
Using Procedures and Exception Handling
Exception Handling .NET MVC
Web Development in Microsoft Visual Studio 2013
Social Media And Global Computing Introduction to Visual Studio
Understanding the Visual IDE
Presentation transcript:

Introduction to ASP.NET, Second Edition2 Chapter Objectives

Introduction to ASP.NET, Second Edition3 Error Handling Error handling –Collection of techniques to identify programming errors Many errors caused by incorrect syntax or spelling –Easily identified using IntelliSense Write code that during program execution, can –Interpret error messages –Execute when an error is detected –Generate custom error messages and global error handlers

Introduction to ASP.NET, Second Edition4 Creating a Custom Error Page Using the Web Configuration File ErrorPage attribute of the Page property –Identifies the generic error page –When an error occurs, the client is redirected to this error page nogarden.aspx?aspxerrorpath=/chapter10/garden.aspx The custom error page can also be set in the customErrors node in the Web.config file Status message codes exposed by the HTTPStatusCode property of the System.NET namespace

Introduction to ASP.NET, Second Edition5 Common Error Status Messages

Introduction to ASP.NET, Second Edition6 Creating a Custom Error Page Using the Web Configuration File (continued)

Introduction to ASP.NET, Second Edition7 Creating a Custom Error Page Using the Web Configuration File (continued)

Introduction to ASP.NET, Second Edition8 Using the Exception Classes to Identify Errors An exception –An object thrown when a predefined error occurs.NET System class contains an Exception class that acts as the base class for all exceptions SystemException class –Base class for all predefined exceptions ApplicationException –Base class to create user-defined exception objects

Introduction to ASP.NET, Second Edition9 Using the Exception Classes to Identify Errors (continued) Common exceptions –Handled with the Try-Catch-Finally statement –SqlException, OleDbException, NullReferenceException, and IndexOutOfRangeException SqlException –Thrown when an error occurs from the SQL Server DataAdapter –Often thrown when the database server does not exist

Introduction to ASP.NET, Second Edition10 Using the Exception Classes to Identify Errors (continued) OleDbException –error occurs from the OleDbDataAdapter NullReferenceException –error occurs when a null object is referenced IndexOutOfRangeException –Array object is improperly indexed The ExternalException –other classes to indirectly inherit from the SystemException class

Introduction to ASP.NET, Second Edition11 Using the Exception Classes to Identify Errors (continued) Exception object is created from the SystemException class Properties exposed from the SystemException class –Message property- TargetSite property –Helplink property- StackTrace property –InnerException property- ToString method

Introduction to ASP.NET, Second Edition12 Application-Level Error Handling Global Application File –Text file that –Contains scripts executed when Web application starts and ends; Browser session starts and ends –Only one Global Application File –Located in the root directory –Contains only server-side scripts

Introduction to ASP.NET, Second Edition13 Application-Level Error Handling (continued) Subroutines available in the Global Application File –Application_OnStart –Application_OnEnd –Session_OnStart –Session_OnEnd HttpContext class –Allows you to tetrieve information about an exception

Introduction to ASP.NET, Second Edition14 Application-Level Error Handling (continued) ToString method – fully qualified name of the object and other properties GetLastError method from HttpServerUtility class –Retrieve the last exception thrown by the application ClearError method from the HttpContext class –Clear all errors from the application Error property of the HttpContext class –Redirect the client to a new URL when a general exception occurs

Introduction to ASP.NET, Second Edition15 Creating a Global Error Page Using the Global Application File Upsize the TaraStore.mdb file to Ch10TaraStoreSQL Run Ch10TaraStoreSQL.bat file to create stored procedures Add data connection to Web Form1.aspx Copy connection string to CS key in the Web.config Save and build the project View CatMenu.aspx to test the data connection

Introduction to ASP.NET, Second Edition16 Web.config

Introduction to ASP.NET, Second Edition17 CatMenu.aspx

Introduction to ASP.NET, Second Edition18 Creating a Global Error Page Using the Global Application File (continued) Modify the Global.asax file Modify the Ch10Products.vb to cause an error –Change CS to CS2 Save and build solution Modify CustomError.aspx page Save and build solution View CatMenu.aspx page. Remove the error, save and build the solution

Introduction to ASP.NET, Second Edition19 Global.asax

Introduction to ASP.NET, Second Edition20 CustomError.aspx

Introduction to ASP.NET, Second Edition21 CatMenu.aspx

Introduction to ASP.NET, Second Edition22 Using Try-Catch-Finally to Handle Specific Errors Try-Catch-Finally statement –Run a block of code when an error has occurred –Goal - to gracefully recover when an exception occurs Try statement attempts to run a block of code If an error exists –An exception object is created –Catch statement catches the error as an exception –Use the Catch multiple times to catch multiple errors Finally statement - execute a block of code

Introduction to ASP.NET, Second Edition23 Using Try-Catch-Finally to Handle Specific Errors (continued)

Introduction to ASP.NET, Second Edition24 Using Try-Catch-Finally to Handle Specific Errors (continued)

Introduction to ASP.NET, Second Edition25 Using the Visual Studio.NET Debugger Visual Studio.NET provides several debugging tools to debug.NET applications A debugger –Step through the application at breakpoints, Defined points in the program where processing stops so that you can view the variables, properties, and other application settings –This data can be helpful when trying to locate programming logic errors

Introduction to ASP.NET, Second Edition26 Using the Visual Studio.NET Debugger (continued) Turned on debugging at page level or in Web.config <compilation debug="true" explicit="true" strict="true" defaultLanguage="vb"> Debug menu commands to step through the code: –Step Over (F10) –Step Into (F11) –Step Out (Shift+F11) –Run to Cursor (Ctrl+F10)

Introduction to ASP.NET, Second Edition27 Using the Visual Studio.NET Debugger (continued) Modify Web.config to turn the debugger on. Set the breakpoint on line 34 in CatMenuList.aspx Click the Debug from the menu bar, and then click Start Click Debug on the menu bar then Step Into Continue to step through 7 more times Click the Locals tab to view the Locals window Exit the debugger and remove the breakpoint

Introduction to ASP.NET, Second Edition28 Using the Visual Studio.NET Debugger (continued)

Introduction to ASP.NET, Second Edition29 Using the Visual Studio.NET Debugger (continued)

Introduction to ASP.NET, Second Edition30 Using the Visual Studio.NET Debugger (continued)

Introduction to ASP.NET, Second Edition31 Documenting the Web Site Important to document Web applications –Programmers can read the documentation –Quickly make the appropriate changes Comment Code Web Report Most of the report features will only work with C#

Introduction to ASP.NET, Second Edition32 Documenting the Web Site (continued)

Introduction to ASP.NET, Second Edition33 Documenting the Web Site (continued)

Introduction to ASP.NET, Second Edition34 Documenting the Web Site (continued)

Introduction to ASP.NET, Second Edition35 Page Output Caching –Technique of caching ASP.NET pages When a Web page is compiled, the page is stored on the server in the cache –When another request is made for the same page, the page from the cache is returned to the client –Storing Web pages in the cache increases the performance of your Web application

Introduction to ASP.NET, Second Edition36 Page Output Caching (continued) Configure the Page Output Cache in the Web page OutPutCache directive Duration parameter –How long in seconds the document is left in cache VaryByParam parameter –Cache any parameters passed with the page request

Introduction to ASP.NET, Second Edition37 Page Output Caching (continued) Additional techniques to control how the page is cached VaryByCustom – create custom strings to determine if a page should be cached VaryByHeader – control cached settings based on the HTTP header that is sent with the request VaryByControl – use fragment caching to cache one or more user controls on the Web page

Introduction to ASP.NET, Second Edition38 Page Output Caching (continued) Modify CatMenuCache.aspx Change Label lblMsg.Text = DateTime.Now.ToString("D") & _ " " & DateTime.Now.ToString("T") Change OutputCache OutputCache Duration="60"  VaryByParam="CatID, selItem" %>

Introduction to ASP.NET, Second Edition39 Page Output Caching (continued)

Introduction to ASP.NET, Second Edition40 Deploying an ASP.NET Web Application Previous versions of ASP to install a component: –Stop the Web service –Log into the Web server locally –Copy the component software to the server –Register the component using RegServ32.exe –Restart the Web Service Today – no stopping of the server or registration

Introduction to ASP.NET, Second Edition41 Deploying an ASP.NET Web Application (continued) Local application cache –default location for the assemblies for the local application Global assembly cache –location for assemblies available to the entire server –can be shared by multiple applications

Introduction to ASP.NET, Second Edition42 Deploying an ASP.NET Web Application (continued) To install a compiled DLL –Copy the DLL file to the bin directory (contains all of the code behind the page compiled into the assembly) –Copy the Web pages (.aspx) and accessory files (css, images etc) to the server AppDomain class manages the application process

Introduction to ASP.NET, Second Edition43 Chapter Summary Error handling allows you to identify programming errors Status message codes provide information about some errors The most common error message is the File Not Found The SystemException class is the base ex The Global Application File is a text file that contains scripts, Try-Catch-Finally statement allows you to attempt to run a block of code that detects when an error has occurred

Introduction to ASP.NET, Second Edition44 Chapter Summary (continued) A debugger allows you to step through the application at defined points called breakpoints The Code Comment Web Report contains information about the objects in your application Page Output Caching allows you to cache pages on the server Local application cache is the location for assemblies for the local application