SlideShare a Scribd company logo
ASP.NET Best Practices	- Useful Tips from the Trenches HabeebRushdan, MCT hrushdan@lowerhead.com LowerHead Consulting, LLC
Target Audience (Why should I sit through this session anyway?) Programmers new to .NET Development Any non-programmer(even those IT gals & guys) interesting in learning about ASP.NET Development Existing ASP.NET web developers interesting in learning a few best practices… we only have a little over an  hour so we can’t cover too much!
Agenda Introductions Brief Introduction of ASP.NET Best Practice Examples More Best Practice Examples A bit More Best Practice Examples… Useful Websites & Articles Conclusion
About your Presenter 10 + Years  working Professionally in the Technology Field Microsoft Certified Trainer (MCT) Microsoft Certified Professional Developer (MCPD: Web Developer) Microsoft Certified Technology Specialist (MCTS: .NET Framework 3.5, ASP.NET Applications) Microsoft Certified Technology Specialist (MCTS: .NET Framework 2.0: Web Applications) Microsoft Certified Application Developer (MCAD.NET) Adobe Certified Instructor - Flash Adobe Certified Expert (ACE - Flash CS3 Professional) Macromedia Certified Flash MX Developer
A little bit about you… Who are you? I really want to know…  (Sorry CSI, I couldn’t resist!)
What is ASP.NET??? A series of Classes that live in the System.Web Assembly Provides the ability to easily create dynamic websites and applications in the .NET Framework Has all the benefits of OOP and the ability to access the thousands of classes built-in to Microsoft’s .NET Framework Class Library
Demo Time – Using Object Browser to look into System.Web Assembly’s Types
ASP.NET Page Execution Life-Cycle A series of ASP.NET Page Events that occur in a specific order Occurs every time you make a Request to an ASP.NET Page Whether it is the first time you visit a page or any additional PostBack to the same page!
ASP.NET Page Life-Cycle Events  PreInit Init InitComplete PreLoad Load Control events  e.g Button1_Click, UserNameTextBox_TextChanged LoadComplete PreRender SaveStateComplete Render Unload
Some of most commonly used ASP.NET Page Life-Cycle Events  PreInit Set a Master page or Theme dynamically Load Set properties in controls and grab data to be bound to controls that allow Data-binding PreRender Make final changes to the contents of the page or its controls e.g. attaching custom HTML attributes to a Button
Demo Time – Handling Page Events
Tips for Creating WebSites Start with a Blank Solution Separate out your Application into logical Tiers Separate Projects for UI, Business Rules, Data-Access, etc Create a BasePage that other pages will inherit from Use MasterPages for consistent layout Use UserControls for reusable UI functionality
Demo Time – Creating a WebSite
State Management Options in ASP.NET ViewState Session Application Cache
ViewState Maintains state at the Page/Control level Is stored in a Hidden Form Input Element on the Client  It can get very large, very quickly so beware and disable it where possible
ASP.NET Control Tips Don’t use a <ASP:Label> Server-side Tag when a caption will not be changed programmatically. Instead, a good Ole’ <Span> Client-side Tag will suffice Disable ViewState in controls that don’t need to maintain their state during PostBacks
Demo Time - ViewState
Session Maintains state at the Session level (generally speaking, per a user’s browser instance) Items are accessible from Page to Page Keep in mind that Items stored In Session “linger” until they Expire Don’t overuse or your web server’s memory will complain! Make sure any custom types you define that need to be stored in Session are marked “Serializable”
Cache Robust Application-wide and Non-Session specific state management object Provides many options for Item Expiration and Dependencies
Cache & Application Suggestions Use the Cache Object instead of the legacy Application Object Cache provides tons of more options for intelligently managing your application-wide state data Compare the options available with Application.Add to the Cache.Add & Cache.Insert
State Management NO NOs Don’t store unmanaged objects in State Management For example: No DataReaders No File Handles (however, the contents of a file stored as System.String is OK)
State Management Suggestions Always check for the existence of an object before accessing it (also called defensive programming) Use string constants for keys This prevents misspellings and other nasty side-effects Consider using a “Manager” pattern with State Management objects
Demo Time – SessionManager Class
Some General Tips Dispose of unmanaged resources after their use This is especially important in web applications because of their disconnected nature Therefore, indulge the “using” statement Make sure you have a robust exception handling strategy Use Try/Catch/Finally where potential issues may occur and have a consistent logical way of dealing with exceptions
Exception Handling in ASP.NET Web.config page redirect option Page_Error Application_Error
ASP.NET AJAX Options Server-side AJAX Using UpdatePanels with existing ASP.NET controls to “trick” the client that PostBacks are not occurring Client-side AJAX No trickery involved but more work & better bang for the buck
AJAX Tips Minimize the use of Server-side AJAX and Update Panels Bad for performance and may cause some unexpected results Embrace Client-side AJAX (true AJAX) Microsoft makes it easy but you will need to learn some JavaScript Don’t be scared… JavaScript is fun and exceptionally versatile!
Demo Time – Client side AJAX
Any Tips you would like to Add? Come on, don’t be shy… We won’t bite ya… we just had some free pizza!
What have you learned? An Overview of ASP.NET Several ASP.NET Best Practices
Useful Websites & Articles Microsoft’s Official Developer Network Site http://www.msdn.com ASP.NET Official Web Site http://www.asp.net/ http://www.asp.net/ajax/ CodeProject Web Site http://www.codeproject.com/
Conclusion Questions?/Comments… As always, “Live long and code proper!”

More Related Content

Viewers also liked

Monitoring web application response times, a new approach
Monitoring web application response times, a new approachMonitoring web application response times, a new approach
Monitoring web application response times, a new approach
Mark Friedman
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
shan km
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
Amelina Ahmeti
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
Rasan Samarasinghe
 
ASP.NET Core Security
ASP.NET Core SecurityASP.NET Core Security
ASP.NET Core Security
Albert Weinert
 
DITEC - Programming with Java
DITEC - Programming with JavaDITEC - Programming with Java
DITEC - Programming with Java
Rasan Samarasinghe
 
Writing clean code in C# and .NET
Writing clean code in C# and .NETWriting clean code in C# and .NET
Writing clean code in C# and .NET
Dror Helper
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Netvidyamittal
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
dimuthu22
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web applicationRahul Bansal
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
Alex Thissen
 
DIWE - Introduction to Web Technologies
DIWE - Introduction to Web TechnologiesDIWE - Introduction to Web Technologies
DIWE - Introduction to Web Technologies
Rasan Samarasinghe
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 

Viewers also liked (15)

Monitoring web application response times, a new approach
Monitoring web application response times, a new approachMonitoring web application response times, a new approach
Monitoring web application response times, a new approach
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
 
ASP.NET Core Security
ASP.NET Core SecurityASP.NET Core Security
ASP.NET Core Security
 
DITEC - Programming with Java
DITEC - Programming with JavaDITEC - Programming with Java
DITEC - Programming with Java
 
Writing clean code in C# and .NET
Writing clean code in C# and .NETWriting clean code in C# and .NET
Writing clean code in C# and .NET
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
 
DIWE - Introduction to Web Technologies
DIWE - Introduction to Web TechnologiesDIWE - Introduction to Web Technologies
DIWE - Introduction to Web Technologies
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 

Similar to ASP.NET Best Practices - Useful Tips from the Trenches

WordCamp Denmark Keynote
WordCamp Denmark KeynoteWordCamp Denmark Keynote
WordCamp Denmark Keynote
Frederick Townes
 
Slideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You QueueSlideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You Queue10n Software, LLC
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
John Pape
 
IEEE KUET SPAC presentation
IEEE KUET SPAC  presentationIEEE KUET SPAC  presentation
IEEE KUET SPAC presentation
ahsanmm
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
Volkan Uzun
 
Intro to Application Express
Intro to Application ExpressIntro to Application Express
Intro to Application Express
José Angel Ibarra Espinosa
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
Ganuka Yashantha
 
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
Perficient, Inc.
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
SAMIR BHOGAYTA
 
Test automation process
Test automation processTest automation process
Test automation process
Bharathi Krishnamurthi
 
PAC 2019 virtual Arjan Van Den Berg
PAC 2019 virtual Arjan Van Den Berg  PAC 2019 virtual Arjan Van Den Berg
PAC 2019 virtual Arjan Van Den Berg
Neotys
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbsvarien
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code projectPruthvi B Patil
 

Similar to ASP.NET Best Practices - Useful Tips from the Trenches (20)

WordCamp Denmark Keynote
WordCamp Denmark KeynoteWordCamp Denmark Keynote
WordCamp Denmark Keynote
 
Slideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You QueueSlideshare - Magento Imagine - Do You Queue
Slideshare - Magento Imagine - Do You Queue
 
North east user group tour
North east user group tourNorth east user group tour
North east user group tour
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
IEEE KUET SPAC presentation
IEEE KUET SPAC  presentationIEEE KUET SPAC  presentation
IEEE KUET SPAC presentation
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
Intro to Application Express
Intro to Application ExpressIntro to Application Express
Intro to Application Express
 
Test
TestTest
Test
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
Portal Deployment Best Practices | IBM Portal Excellence Conference 2009
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
 
Test automation process _ QTP
Test automation process _ QTPTest automation process _ QTP
Test automation process _ QTP
 
Test automation process
Test automation processTest automation process
Test automation process
 
PAC 2019 virtual Arjan Van Den Berg
PAC 2019 virtual Arjan Van Den Berg  PAC 2019 virtual Arjan Van Den Berg
PAC 2019 virtual Arjan Van Den Berg
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
 
Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbs
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code project
 

Recently uploaded

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

ASP.NET Best Practices - Useful Tips from the Trenches

  • 1. ASP.NET Best Practices - Useful Tips from the Trenches HabeebRushdan, MCT hrushdan@lowerhead.com LowerHead Consulting, LLC
  • 2. Target Audience (Why should I sit through this session anyway?) Programmers new to .NET Development Any non-programmer(even those IT gals & guys) interesting in learning about ASP.NET Development Existing ASP.NET web developers interesting in learning a few best practices… we only have a little over an hour so we can’t cover too much!
  • 3. Agenda Introductions Brief Introduction of ASP.NET Best Practice Examples More Best Practice Examples A bit More Best Practice Examples… Useful Websites & Articles Conclusion
  • 4. About your Presenter 10 + Years working Professionally in the Technology Field Microsoft Certified Trainer (MCT) Microsoft Certified Professional Developer (MCPD: Web Developer) Microsoft Certified Technology Specialist (MCTS: .NET Framework 3.5, ASP.NET Applications) Microsoft Certified Technology Specialist (MCTS: .NET Framework 2.0: Web Applications) Microsoft Certified Application Developer (MCAD.NET) Adobe Certified Instructor - Flash Adobe Certified Expert (ACE - Flash CS3 Professional) Macromedia Certified Flash MX Developer
  • 5. A little bit about you… Who are you? I really want to know… (Sorry CSI, I couldn’t resist!)
  • 6. What is ASP.NET??? A series of Classes that live in the System.Web Assembly Provides the ability to easily create dynamic websites and applications in the .NET Framework Has all the benefits of OOP and the ability to access the thousands of classes built-in to Microsoft’s .NET Framework Class Library
  • 7. Demo Time – Using Object Browser to look into System.Web Assembly’s Types
  • 8. ASP.NET Page Execution Life-Cycle A series of ASP.NET Page Events that occur in a specific order Occurs every time you make a Request to an ASP.NET Page Whether it is the first time you visit a page or any additional PostBack to the same page!
  • 9. ASP.NET Page Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events e.g Button1_Click, UserNameTextBox_TextChanged LoadComplete PreRender SaveStateComplete Render Unload
  • 10. Some of most commonly used ASP.NET Page Life-Cycle Events PreInit Set a Master page or Theme dynamically Load Set properties in controls and grab data to be bound to controls that allow Data-binding PreRender Make final changes to the contents of the page or its controls e.g. attaching custom HTML attributes to a Button
  • 11. Demo Time – Handling Page Events
  • 12. Tips for Creating WebSites Start with a Blank Solution Separate out your Application into logical Tiers Separate Projects for UI, Business Rules, Data-Access, etc Create a BasePage that other pages will inherit from Use MasterPages for consistent layout Use UserControls for reusable UI functionality
  • 13. Demo Time – Creating a WebSite
  • 14. State Management Options in ASP.NET ViewState Session Application Cache
  • 15. ViewState Maintains state at the Page/Control level Is stored in a Hidden Form Input Element on the Client It can get very large, very quickly so beware and disable it where possible
  • 16. ASP.NET Control Tips Don’t use a <ASP:Label> Server-side Tag when a caption will not be changed programmatically. Instead, a good Ole’ <Span> Client-side Tag will suffice Disable ViewState in controls that don’t need to maintain their state during PostBacks
  • 17. Demo Time - ViewState
  • 18. Session Maintains state at the Session level (generally speaking, per a user’s browser instance) Items are accessible from Page to Page Keep in mind that Items stored In Session “linger” until they Expire Don’t overuse or your web server’s memory will complain! Make sure any custom types you define that need to be stored in Session are marked “Serializable”
  • 19. Cache Robust Application-wide and Non-Session specific state management object Provides many options for Item Expiration and Dependencies
  • 20. Cache & Application Suggestions Use the Cache Object instead of the legacy Application Object Cache provides tons of more options for intelligently managing your application-wide state data Compare the options available with Application.Add to the Cache.Add & Cache.Insert
  • 21. State Management NO NOs Don’t store unmanaged objects in State Management For example: No DataReaders No File Handles (however, the contents of a file stored as System.String is OK)
  • 22. State Management Suggestions Always check for the existence of an object before accessing it (also called defensive programming) Use string constants for keys This prevents misspellings and other nasty side-effects Consider using a “Manager” pattern with State Management objects
  • 23. Demo Time – SessionManager Class
  • 24. Some General Tips Dispose of unmanaged resources after their use This is especially important in web applications because of their disconnected nature Therefore, indulge the “using” statement Make sure you have a robust exception handling strategy Use Try/Catch/Finally where potential issues may occur and have a consistent logical way of dealing with exceptions
  • 25. Exception Handling in ASP.NET Web.config page redirect option Page_Error Application_Error
  • 26. ASP.NET AJAX Options Server-side AJAX Using UpdatePanels with existing ASP.NET controls to “trick” the client that PostBacks are not occurring Client-side AJAX No trickery involved but more work & better bang for the buck
  • 27. AJAX Tips Minimize the use of Server-side AJAX and Update Panels Bad for performance and may cause some unexpected results Embrace Client-side AJAX (true AJAX) Microsoft makes it easy but you will need to learn some JavaScript Don’t be scared… JavaScript is fun and exceptionally versatile!
  • 28. Demo Time – Client side AJAX
  • 29. Any Tips you would like to Add? Come on, don’t be shy… We won’t bite ya… we just had some free pizza!
  • 30. What have you learned? An Overview of ASP.NET Several ASP.NET Best Practices
  • 31. Useful Websites & Articles Microsoft’s Official Developer Network Site http://www.msdn.com ASP.NET Official Web Site http://www.asp.net/ http://www.asp.net/ajax/ CodeProject Web Site http://www.codeproject.com/
  • 32. Conclusion Questions?/Comments… As always, “Live long and code proper!”