ASPNET_BestPractices_DevChat3
ASPNET_BestPractices_DevChat3
ASP.NET Development
Ammar Abuthuraya
Developer & Platform Lead
Microsoft Corporation
What we will cover
Designing ASP.NET Web forms
Use code-behind for best performance and scalability
ASP.NET caching techniques
State management options
Recommendations for communicating with COM components from ASP.NET
Session Prerequisites
Understand .NET architecture
Working knowledge of either VB.NET or C#
Knowledge of ASP.NET application architecture
Knowledge of ASP
Level 300
So Why This Presentation?
You know how to build ASP applications and use the same techniques to build ASP.NET
applications
You want to leverage the power and capabilities of ASP.NET
You want to use ASP.NET to build high-performance, scalable, web-based applications
Demonstrations
Language best practices
Server Control design practices
Component & user control design
State management recommendations
Caching techniques
Measuring performance
Agenda
Language and Code Practices
Server Control Design Practices
Component and User Control Usage Practices
State Management Recommendations
Deployment Best Practices
Measurement Techniques
Language and Code Practices
Code Performance
.NET Common Language Runtime (CLR) provides big runtime performance wins
Further optimize by native code generation using NGEN.EXE
No perf difference in .NET languages
Equivalent code written in VB and C# provides equivalent performance at runtime
Language and Code Practices
Binding in VB.NET
Early binding in VB performs better than
late binding
‘ VB Late Binding Example
Dim j, obj
obj = New System.Collections.ArrayList()
for j = 0 To i
obj.Add(j)
Next
Buffered Output
Fragment Caching & Custom Caching
Code Behind, User Controls & Components
Data Flow Across Tiers
Optimizing Postback
Agenda
Language and Code Practices
Server Control Design Practices
Component and User Control Usage Practices
State Management Recommendations
Deployment Best Practices
Measurement Techniques
State Management Recommendations
in Proc Session State
Session state is stored in the ASP.NET worker process
Recycling the process will cause all session state to be lost
Session state performance is maximum in this mode
State Management Recommendations
Out of Proc Session State
Session state can be stored in a State server process running
on the same machine or a different machine
State can also be stored in a SQL Server database
Restarting the web server does not cause the session state to
be lost
More reliable than in process session state but less
performant
State Management Recommendations
Configuring Session State
Session state can be configured via the <sessionState>
element in the web.config file
Change causes ASP.NET application to be restarted, all
new sessions will be stored as per the updated session
configuration
Out of process session state stores like State Server or
SQL Server must be started & configured properly
Demonstration 4
State Management Best Practices
State Management
Session State in A State Server
Agenda
Language and Code Practices
Server Control Design Practices
Component and User Control Usage Practices
State Management Recommendations
Deployment Best Practices
Measurement Techniques
Deployment Best Practices
Logical Design
Design your applications using logical 3-Tier Design Practices:
Pages (.aspx) and User Controls (.ascx)
Reusable Biz Classes in \bin dir (.vb + .cs)
Data within a SQL Database
Design your Web application so that it can be distributed across a Web farm
Your code shouldn’t assume that a client will always return to the same machine
Be careful of assumptions regarding statics and application state
Deployment Best Practices
Physical Deployment
Deploy your applications such that the pages and components run in
same process
Deploying onto remote servers connected via DCOM or Web Services will almost
always hurt your performance/scalability
Leverage Web services only for application to application communication -- not
intra app calls
Leverage ISA Server for configurations where a DMZ security zone is
required
Enables you to restrict app server access from browser clients
Deployment Best Practices
ISA for DMZ Configurations
DMZ (firewalled)
Performance Measurement
Session Summary
in this session we discussed:
Language and Code Practices
Server Control Design Practices
Component and User Control Usage Practices
State Management Recommendations
Caching Techniques
Deployment Best Practices
Measurement Techniques
for More information…
MSDN Web site at
msdn.microsoft.com
MSDN
Essential Resources for Developers
Subscription Library, OS, Professional, Enterprise,
Services Universal Delivered via CD-ROM, DVD, Web
http://www.microsoft.com/usa/webcasts
MSDN Subscriptions
THE way to get Visual Studio .NET
Visual Studio .NET MSDN Subscriptions
Enterprise Architect
• Software and data modeling MSDN Universal
• Enterprise templates $2799 new
• Architectural guidance $2299 renewal/upgrade
Enterprise Developer
• Enterprise lifecycle tools MSDN Enterprise
• Team development support $2199 new
• Core .NET Enterprise $1599 renewal/upgrade
NEW
Servers
Professional
• Tools to build applications MSDN Professional
and XML Web services for $1199 new
Windows and the Web $899 renewal/upgrade
Where Can I Get MSDN?
Visit MSDN Online at
msdn.microsoft.com
Register for the MSDN Flash Email
Newsletter at
msdn.microsoft.com/flash
Become an MSDN CD Subscriber at
msdn.microsoft.com/subscriptions
MSDN online seminars
msdn.microsoft.com/training/seminars
Attend More MSDN Events
MS Press
Essential Resources for Developers