SlideShare a Scribd company logo
Tips and Tricks in ASP.NET 2.0 Development Talal Abdullah Alsubaie Programmer IT Department Saudi Food and Drugs Authority Talal A. Alsubaie  SFDA
Tips and Tricks in ASP.NET 2.0 Development This presentation aims to give us (Developers) better knowledge in development in MS ASP.NET 2.0 environment.  Knowing some tips and tricks in ASP.NET 2.0 programming. The main goal is to enhance: Security. Availability. Integrity. Usability. Performance. Talal A. Alsubaie  SFDA
Tips and Tricks in ASP.NET 2.0 Development We will cover some topics in this presentation such as: N-Tier Architecture. CSS (Cascading Style Sheets)Pages. Database Programming Exception  Handling. Talal A. Alsubaie  SFDA
N-Tier Architecture Talal A. Alsubaie  SFDA
N-Tier Architecture An N-Tier architecture is a development method that  user interface ,  functional process logic ,  data storage , and  data access  are developed and maintained as independent model.  ( http://en.wikipedia.org/wiki/N_tier ) . The N-Tier architecture is based on the concept of separating a system to different layers (usually 3) Each layer interacts with only the layer directly below, and has specific function that it is responsible for. It is considered as a  Software Design Pattern .  N-Tier provides reusability, scalability, maintainability. Web development often use the 3-Tier model. A Three-Tier model has. Presentation Tier. Business Tier. Data Tier. Talal A. Alsubaie  SFDA
Talal A. Alsubaie  SFDA Database Get Salary Total Get Last Year Salaries Query Salary 1 Salary 2 Salary 3 Add Salary Together Display Total
N-Tier Architecture One of the common mistakes is tightly coupling layers, and writing  business logic in presentation tier. Talal A. Alsubaie  SFDA
Database Programming Talal A. Alsubaie  SFDA
Database Programming You Have Many Things to Think About Talal A. Alsubaie  SFDA
Database Programming Things to put in mind: Keep the connection string in web.config. Never store sensitive data in clear-text within a database. Do not rely on Client Side validation. Validate input for length, range, format, and type. Validate un trusted input passed to your data access methods. When constructing SQL queries, use type safe SQL parameters. Avoid Dynamic SQL that accepts user input. Be aware of SQL Injections. Talal A. Alsubaie  SFDA
Database Programming Keep the connection string in web.config: Web.config is a XML file that stores configuration settings for an ASP.NET application.  Why would you want to keep your database connection strings in the Web.config file? Easier maintenance and deployment. Use CustomErrors and keep the mode = “On”. Disable trace for production; else take a look at “ trace.axd ”. Disable Debugging. The Web.Config is not accessible by the server. “ You can read it using the file system ”. The .NET framework will take care of web.config security. Talal A. Alsubaie  SFDA
Database Programming Never store sensitive data in clear-text within a database: No application is 100% secure. The attacker can enter your database without using your application. The attacker can use MS SQL Server Management Studio or use his own application to enter your database. Talal A. Alsubaie  SFDA
Database Programming Do not rely on Client Side validation: Client side validation can easily bypassed. What if the user disables JavaScript?! Use client side validation plus server side validation. Talal A. Alsubaie  SFDA
Database Programming Validate input for length, range, format, and type: Do not trust user input. Attacker can pass malicious input.  i.e. SQL Injections. Use Regex class to validate input.  (Regular Expressions). For example an E-mail regular expression is: [A-Za-z] + [A-Za-z0-9_.-]* @ [A-Za-z0-9-]+ . [A-Za-z]{2,3} Take a look at: http://regexlib.com Talal A. Alsubaie  SFDA
Database Programming What is a SQL Injection Attack? Many web applications take user input from a form. Often this user input is used literally in the construction of a SQL query submitted to a database. For example: SELECT productdata FROM products WHERE  productname = ‘ user input product name ’; A SQL injection attack involves placing SQL statements in the user input. Talal A. Alsubaie  SFDA
Database Programming SQL Injections: Database layer vulnerability. Characters like ’ and ; have special meaning  to SQL engine. Attacker can benefit of: Unauthorized data access. Execute arbitrary commands. RFID Injections: What if a clever person doctored a tag to include extra characters in that item number? Talal A. Alsubaie  SFDA
Demo Talal A. Alsubaie  SFDA
Database Programming When constructing SQL queries, use type safe SQL parameters  : Use type safe SQL parameters to avoid possible SQL injection attacks that can occur with unfiltered input. You can use type safe parameters with stored procedures and with dynamic SQL statements. Parameters are also checked for type and length. using  System.Data; using  System.Data.SqlClient; using  (SqlConnection connection =  new  SqlConnection(connectionString)) { DataSet userDataset =  new  DataSet(); SqlDataAdapter myCommand =  new  SqlDataAdapter(“LoginStoredProcedure", connection); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; myCommand.SelectCommand.Parameters.Add("@au_id", SqlDbType.VarChar, 11); myCommand.SelectCommand.Parameters["@au_id"].Value = SSN.Text; myCommand.Fill(userDataset); } Talal A. Alsubaie  SFDA
Database Programming Avoid Dynamic SQL that accepts user input: Avoid constructing SQL queries in code that include user input. instead, prefer parameterized store procedures that use type safe SQL parameters. If you construct queries dynamically using user input, your code is susceptible to SQL injection.  Talal A. Alsubaie  SFDA // Use dynamic SQL SqlDataAdapter myCommand =  new  SqlDataAdapter( "SELECT au_lname, au_fname FROM authors WHERE au_id = '" +  SSN.Text + "'", myConnection); SELECT  au_lname, au_fname  FROM  authors  WHERE  au_id = '';  DROP   DATABASE  HR--'
Database Programming Conclusion: Do not trust any input data. Use Regular Expressions to validate data. Use parameterized SQL input.  Don’t interact with database directly; instead use stored  procedures. Talal A. Alsubaie  SFDA
Cascading Style Sheets CSS Talal A. Alsubaie  SFDA
Cascading Style Sheets (CSS) CSS stands for Cascading Style Sheets.  Styles define how to display HTML elements. Styles are normally stored in Style Sheets.  External Style Sheets can save you a lot of work.  External Style Sheets are stored in CSS files.  Multiple style definitions will cascade into one.  Separating the content and presentation. Talal A. Alsubaie  SFDA
Cascading Style Sheets (CSS) selector {property: value;} Selector:  The HTML element you wish to define. Property: Attribute you wish to change. Value: Value the property takes. Talal A. Alsubaie  SFDA
Cascading Style Sheets (CSS) What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles will &quot;cascade&quot; into a new &quot;virtual&quot; style sheet by the following rules, where number four has the highest priority:  Browser default. External style sheet. Internal style sheet (inside the <head> tag).  Inline style (inside an HTML element).  Talal A. Alsubaie  SFDA
Demo Talal A. Alsubaie  SFDA
Cascading Style Sheets (CSS) How can you use CSS files? Create a .CSS file. Enter your CSS code. In your .HTML or .ASPX page add: <link rel=&quot;stylesheet&quot; href=“ css_file_path.css &quot; type=&quot;text/css&quot;/> inside your head tag. For example: <head> <title> My Title </title> <link  rel=&quot;stylesheet&quot; href=&quot;MyStyle.css&quot; type=&quot;text/css&quot;  /> </head> Talal A. Alsubaie  SFDA
Cascading Style Sheets (CSS) Benefits of Cascading Style Sheets: Separate content from presentation. Look and feel consistency. Web site maintenance. Talal A. Alsubaie  SFDA
Exception Handling Talal A. Alsubaie  SFDA
Exception Handling Exceptions are: Error that occurs at execution time. Abnormal termination of program. Wrong execution result. Exception handling:   is a programming language construct mechanism designed to handle the occurrence of some condition that changes the normal flow of execution. Talal A. Alsubaie  SFDA
Exception Handling Talal A. Alsubaie  SFDA Syntax: Try  { //Code that may raise exception.  } Catch  (Exception1 e){ //Case Exception1 occurs.  } Catch  (Exception2 e){ //Case Exception2 occurs.  } Else { //Case other exception occurs.  } Finally  { //Code to be executed after exception occurs. }
Exception Handling In Exceptions: Plan for the worst. Don’t trust external data. Don’t trust other systems: Databases, or other applications. The only reliable devices are: the screen, the mouse and keyboard. Writes can fail, too.  (Space, Privileges, Physical fault…). Don't put important exception information on the Message field.  (Security). Don't ever swallow exceptions. Cleanup code should be put in finally blocks. Talal A. Alsubaie  SFDA
Exception Handling Objectives: Making safer program by providing special mechanism. Keeps your program running. Don’t scare the user with technical errors. Talal A. Alsubaie  SFDA
Demo Talal A. Alsubaie  SFDA
Q & A Talal A. Alsubaie  SFDA
Thank you Talal Abdullah Alsubaie [email_address] IT Department Saudi Food and Drugs Authority Talal A. Alsubaie  SFDA

More Related Content

PPTX
Using the Tooling API to Generate Apex SOAP Web Service Clients
PDF
Webservices in SalesForce (part 1)
PDF
Metadata API
PDF
PPT
SQL Injection
PPT
Sql Injection Attacks Siddhesh
PDF
Sql Injection Myths and Fallacies
PPT
D:\Technical\Ppt\Sql Injection
Using the Tooling API to Generate Apex SOAP Web Service Clients
Webservices in SalesForce (part 1)
Metadata API
SQL Injection
Sql Injection Attacks Siddhesh
Sql Injection Myths and Fallacies
D:\Technical\Ppt\Sql Injection

What's hot (20)

PDF
Microsoft Information Protection Implementation using C# and PowerShell
PDF
SQL Injection: complete walkthrough (not only) for PHP developers
PDF
Advanced SQL Injection: Attacks
PPTX
Sql injection
PPTX
Secure coding - Balgan - Tiago Henriques
PDF
Best practices in using Salesforce Metadata API
PPT
Sql injection attack
PPT
Web application attacks using Sql injection and countermasures
PDF
Aol
PPT
Sql injection
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
PPT
Advanced SQL Injection
PDF
70562 (1)
PDF
SQL injection: Not only AND 1=1
PDF
What is advanced SQL Injection? Infographic
PDF
Exception Handling
PDF
Oracle Text in APEX
PPTX
Sql server infernals
PPTX
Automated testing with selenium prasad bapatla
ODP
Performance tuning
Microsoft Information Protection Implementation using C# and PowerShell
SQL Injection: complete walkthrough (not only) for PHP developers
Advanced SQL Injection: Attacks
Sql injection
Secure coding - Balgan - Tiago Henriques
Best practices in using Salesforce Metadata API
Sql injection attack
Web application attacks using Sql injection and countermasures
Aol
Sql injection
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Advanced SQL Injection
70562 (1)
SQL injection: Not only AND 1=1
What is advanced SQL Injection? Infographic
Exception Handling
Oracle Text in APEX
Sql server infernals
Automated testing with selenium prasad bapatla
Performance tuning
Ad

Viewers also liked (6)

PDF
e-Learning
PPT
Tema 5
PPT
MuséE Louvre
PPT
Humanities Presentation Template
PPT
3 Farger
PPT
Similarity Search For Web Services
e-Learning
Tema 5
MuséE Louvre
Humanities Presentation Template
3 Farger
Similarity Search For Web Services
Ad

Similar to Selected Topics ASP.NET2 (20)

PPT
Synapseindia dot net development chapter 8 asp dot net
PPTX
PDF
Backpack Tools4 Sql Dev
PDF
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
PPTX
Sql Injection and Entity Frameworks
PDF
Defensive programing 101
PPTX
C# and ASP.NET Code and Data-Access Security
DOCX
unit 3.docx
PPTX
Hard Coding as a design approach
PDF
ASP.NET Unit-3.pdf
PPT
.NET Developer
PDF
ASP NET Professional Projects 1st Edition Hersh Bhasin
PPT
the .NET Framework. It provides the claf
PDF
Professional Adonet 2 Programming With Sql Server 2005 Oracle And Mysql Walla...
PPT
Tips for success: Common mistakes in application development with Firebird an...
PPT
What Are We Still Doing Wrong
DOCX
Framework 4
PPTX
ADO.NET by ASP.NET Development Company in india
PPTX
SQLi for Security Champions
PPTX
Secure coding practices
Synapseindia dot net development chapter 8 asp dot net
Backpack Tools4 Sql Dev
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
Sql Injection and Entity Frameworks
Defensive programing 101
C# and ASP.NET Code and Data-Access Security
unit 3.docx
Hard Coding as a design approach
ASP.NET Unit-3.pdf
.NET Developer
ASP NET Professional Projects 1st Edition Hersh Bhasin
the .NET Framework. It provides the claf
Professional Adonet 2 Programming With Sql Server 2005 Oracle And Mysql Walla...
Tips for success: Common mistakes in application development with Firebird an...
What Are We Still Doing Wrong
Framework 4
ADO.NET by ASP.NET Development Company in india
SQLi for Security Champions
Secure coding practices

More from Talal Alsubaie (9)

PDF
Exploratory Data Analysis
PDF
هل نحتاج لإجراءات العمل Do we need BPM
PDF
9 عوامل تفشل مشاريع توثيق الإجراءات
PPTX
Cloud Computing
PPT
Pattern Recognition
PPT
Bracket Capability For Distributed Systems Security
PPT
Ajax & ASP.NET 2
PPT
Emerging DB Technologies
Exploratory Data Analysis
هل نحتاج لإجراءات العمل Do we need BPM
9 عوامل تفشل مشاريع توثيق الإجراءات
Cloud Computing
Pattern Recognition
Bracket Capability For Distributed Systems Security
Ajax & ASP.NET 2
Emerging DB Technologies

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Spectroscopy.pptx food analysis technology
sap open course for s4hana steps from ECC to s4
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
Spectroscopy.pptx food analysis technology

Selected Topics ASP.NET2

  • 1. Tips and Tricks in ASP.NET 2.0 Development Talal Abdullah Alsubaie Programmer IT Department Saudi Food and Drugs Authority Talal A. Alsubaie SFDA
  • 2. Tips and Tricks in ASP.NET 2.0 Development This presentation aims to give us (Developers) better knowledge in development in MS ASP.NET 2.0 environment. Knowing some tips and tricks in ASP.NET 2.0 programming. The main goal is to enhance: Security. Availability. Integrity. Usability. Performance. Talal A. Alsubaie SFDA
  • 3. Tips and Tricks in ASP.NET 2.0 Development We will cover some topics in this presentation such as: N-Tier Architecture. CSS (Cascading Style Sheets)Pages. Database Programming Exception Handling. Talal A. Alsubaie SFDA
  • 4. N-Tier Architecture Talal A. Alsubaie SFDA
  • 5. N-Tier Architecture An N-Tier architecture is a development method that user interface , functional process logic , data storage , and data access are developed and maintained as independent model. ( http://en.wikipedia.org/wiki/N_tier ) . The N-Tier architecture is based on the concept of separating a system to different layers (usually 3) Each layer interacts with only the layer directly below, and has specific function that it is responsible for. It is considered as a Software Design Pattern . N-Tier provides reusability, scalability, maintainability. Web development often use the 3-Tier model. A Three-Tier model has. Presentation Tier. Business Tier. Data Tier. Talal A. Alsubaie SFDA
  • 6. Talal A. Alsubaie SFDA Database Get Salary Total Get Last Year Salaries Query Salary 1 Salary 2 Salary 3 Add Salary Together Display Total
  • 7. N-Tier Architecture One of the common mistakes is tightly coupling layers, and writing business logic in presentation tier. Talal A. Alsubaie SFDA
  • 8. Database Programming Talal A. Alsubaie SFDA
  • 9. Database Programming You Have Many Things to Think About Talal A. Alsubaie SFDA
  • 10. Database Programming Things to put in mind: Keep the connection string in web.config. Never store sensitive data in clear-text within a database. Do not rely on Client Side validation. Validate input for length, range, format, and type. Validate un trusted input passed to your data access methods. When constructing SQL queries, use type safe SQL parameters. Avoid Dynamic SQL that accepts user input. Be aware of SQL Injections. Talal A. Alsubaie SFDA
  • 11. Database Programming Keep the connection string in web.config: Web.config is a XML file that stores configuration settings for an ASP.NET application. Why would you want to keep your database connection strings in the Web.config file? Easier maintenance and deployment. Use CustomErrors and keep the mode = “On”. Disable trace for production; else take a look at “ trace.axd ”. Disable Debugging. The Web.Config is not accessible by the server. “ You can read it using the file system ”. The .NET framework will take care of web.config security. Talal A. Alsubaie SFDA
  • 12. Database Programming Never store sensitive data in clear-text within a database: No application is 100% secure. The attacker can enter your database without using your application. The attacker can use MS SQL Server Management Studio or use his own application to enter your database. Talal A. Alsubaie SFDA
  • 13. Database Programming Do not rely on Client Side validation: Client side validation can easily bypassed. What if the user disables JavaScript?! Use client side validation plus server side validation. Talal A. Alsubaie SFDA
  • 14. Database Programming Validate input for length, range, format, and type: Do not trust user input. Attacker can pass malicious input. i.e. SQL Injections. Use Regex class to validate input. (Regular Expressions). For example an E-mail regular expression is: [A-Za-z] + [A-Za-z0-9_.-]* @ [A-Za-z0-9-]+ . [A-Za-z]{2,3} Take a look at: http://regexlib.com Talal A. Alsubaie SFDA
  • 15. Database Programming What is a SQL Injection Attack? Many web applications take user input from a form. Often this user input is used literally in the construction of a SQL query submitted to a database. For example: SELECT productdata FROM products WHERE productname = ‘ user input product name ’; A SQL injection attack involves placing SQL statements in the user input. Talal A. Alsubaie SFDA
  • 16. Database Programming SQL Injections: Database layer vulnerability. Characters like ’ and ; have special meaning to SQL engine. Attacker can benefit of: Unauthorized data access. Execute arbitrary commands. RFID Injections: What if a clever person doctored a tag to include extra characters in that item number? Talal A. Alsubaie SFDA
  • 17. Demo Talal A. Alsubaie SFDA
  • 18. Database Programming When constructing SQL queries, use type safe SQL parameters : Use type safe SQL parameters to avoid possible SQL injection attacks that can occur with unfiltered input. You can use type safe parameters with stored procedures and with dynamic SQL statements. Parameters are also checked for type and length. using System.Data; using System.Data.SqlClient; using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet userDataset = new DataSet(); SqlDataAdapter myCommand = new SqlDataAdapter(“LoginStoredProcedure&quot;, connection); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; myCommand.SelectCommand.Parameters.Add(&quot;@au_id&quot;, SqlDbType.VarChar, 11); myCommand.SelectCommand.Parameters[&quot;@au_id&quot;].Value = SSN.Text; myCommand.Fill(userDataset); } Talal A. Alsubaie SFDA
  • 19. Database Programming Avoid Dynamic SQL that accepts user input: Avoid constructing SQL queries in code that include user input. instead, prefer parameterized store procedures that use type safe SQL parameters. If you construct queries dynamically using user input, your code is susceptible to SQL injection. Talal A. Alsubaie SFDA // Use dynamic SQL SqlDataAdapter myCommand = new SqlDataAdapter( &quot;SELECT au_lname, au_fname FROM authors WHERE au_id = '&quot; + SSN.Text + &quot;'&quot;, myConnection); SELECT au_lname, au_fname FROM authors WHERE au_id = ''; DROP DATABASE HR--'
  • 20. Database Programming Conclusion: Do not trust any input data. Use Regular Expressions to validate data. Use parameterized SQL input. Don’t interact with database directly; instead use stored procedures. Talal A. Alsubaie SFDA
  • 21. Cascading Style Sheets CSS Talal A. Alsubaie SFDA
  • 22. Cascading Style Sheets (CSS) CSS stands for Cascading Style Sheets. Styles define how to display HTML elements. Styles are normally stored in Style Sheets. External Style Sheets can save you a lot of work. External Style Sheets are stored in CSS files. Multiple style definitions will cascade into one. Separating the content and presentation. Talal A. Alsubaie SFDA
  • 23. Cascading Style Sheets (CSS) selector {property: value;} Selector: The HTML element you wish to define. Property: Attribute you wish to change. Value: Value the property takes. Talal A. Alsubaie SFDA
  • 24. Cascading Style Sheets (CSS) What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles will &quot;cascade&quot; into a new &quot;virtual&quot; style sheet by the following rules, where number four has the highest priority: Browser default. External style sheet. Internal style sheet (inside the <head> tag). Inline style (inside an HTML element). Talal A. Alsubaie SFDA
  • 25. Demo Talal A. Alsubaie SFDA
  • 26. Cascading Style Sheets (CSS) How can you use CSS files? Create a .CSS file. Enter your CSS code. In your .HTML or .ASPX page add: <link rel=&quot;stylesheet&quot; href=“ css_file_path.css &quot; type=&quot;text/css&quot;/> inside your head tag. For example: <head> <title> My Title </title> <link rel=&quot;stylesheet&quot; href=&quot;MyStyle.css&quot; type=&quot;text/css&quot; /> </head> Talal A. Alsubaie SFDA
  • 27. Cascading Style Sheets (CSS) Benefits of Cascading Style Sheets: Separate content from presentation. Look and feel consistency. Web site maintenance. Talal A. Alsubaie SFDA
  • 28. Exception Handling Talal A. Alsubaie SFDA
  • 29. Exception Handling Exceptions are: Error that occurs at execution time. Abnormal termination of program. Wrong execution result. Exception handling: is a programming language construct mechanism designed to handle the occurrence of some condition that changes the normal flow of execution. Talal A. Alsubaie SFDA
  • 30. Exception Handling Talal A. Alsubaie SFDA Syntax: Try { //Code that may raise exception. } Catch (Exception1 e){ //Case Exception1 occurs. } Catch (Exception2 e){ //Case Exception2 occurs. } Else { //Case other exception occurs. } Finally { //Code to be executed after exception occurs. }
  • 31. Exception Handling In Exceptions: Plan for the worst. Don’t trust external data. Don’t trust other systems: Databases, or other applications. The only reliable devices are: the screen, the mouse and keyboard. Writes can fail, too. (Space, Privileges, Physical fault…). Don't put important exception information on the Message field. (Security). Don't ever swallow exceptions. Cleanup code should be put in finally blocks. Talal A. Alsubaie SFDA
  • 32. Exception Handling Objectives: Making safer program by providing special mechanism. Keeps your program running. Don’t scare the user with technical errors. Talal A. Alsubaie SFDA
  • 33. Demo Talal A. Alsubaie SFDA
  • 34. Q & A Talal A. Alsubaie SFDA
  • 35. Thank you Talal Abdullah Alsubaie [email_address] IT Department Saudi Food and Drugs Authority Talal A. Alsubaie SFDA