Académique Documents
Professionnel Documents
Culture Documents
Development Tips and Tricks Error Handling Tips and Tricks Production Tips and Tricks
Session Prerequisites
Level 300
Agenda
Development Tips and Tricks Error Handling Tips and Tricks Production Tips and Tricks
HttpPostedFile Object:
HttpPostedFile Object:
Demonstration 1
File Upload
File system is not the only option Example: Storing within SQL
Access uploaded file as byte array Store file within SQL as image (blob) Store ContentType and ContentLength also Provide Edit Link to display page Edit Link Page sets ContentType header and then writes binary array back to client
Demonstration 2
File Upload With SQL
Additionally supports resizing & cropping Overlays on top of existing images Read/Write Any Standard IO Stream Dynamically generate GIFs/JPGs from .aspx Set ContentType appropriately Optionally output cache results
System.Drawing
Demonstration 3
Image Generation
Binding options
Built-in caching
Demonstration 4
Static XML
<script language="VB" runat=server> Sub Page_Load(Sender as Object, E as EventArgs) Dim conn as New SqlConnection(connectionString) Dim cmd as New SqlDataAdapter(select * from products", conn) Dim dataset As New DataSet() cmd.Fill (dataset, "dataset") Dim XmlDoc as XmlDocument = New XmlDataDocument(dataset) MyXml1.Document = XmlDoc End Sub </script> <asp:xml id="MyXml1" runat=server/>
Demonstration 5
Dynamically Bind XML
Stored in web.config files Enables devs to avoid hard-coding them Administrators can later change them
Examples:
<configuration>
</configuration>
2.
Demonstration 6
Application Settings
<configuration>
</configuration>
Smooth client UI but with server code Automatic down-level for non-IE browsers
Agenda
Development Tips and Tricks Error Handling Tips and Tricks Production Tips and Tricks
Add trace directive at top of page <%@ Page Trace=True %> Add trace calls throughout page Trace.Write(Button Clicked) Trace.Warn(Value: + value) Access page from browser
1.
1.
Demonstration 7
Page Tracing
<configuration>
</configuration>
2.
http://localhost/approot/Trace.axd
Demonstration 8
Application Tracing
Runtime errors done using exceptions Full call stack information available w/ errors Can catch/handle/throw exceptions in any .NET Language (including VB)
Enable programmatic logging of problems Automatically redirect users to error page when unhandled exceptions occur
Enable programmatic logging of problems Automatically redirect users to error page when unhandled exceptions occur
Provides access to current Request Provides access to Exception object Enables developer to log/track errors
Cool Tip:
Use new EventLog class to write custom events to log when errors occur Use new SmtpMail class to send email to administrators
No ugly exception error messages Enables you to display a pretty site under repair page of your design
Can be configured per status code number Can be configured to only display remotely
Agenda
Development Tips and Tricks Error Handling Tips and Tricks Production Tips and Tricks
Now possible to publish unique applicationspecific performance data Great for real-time application monitoring Example: total orders, orders/sec
Automatic Crash Recovery Automatic Memory Leak Recovery Automatic Deadlock Recovery
Automatic Crash Recovery Automatic Memory Leak Recovery Automatic Deadlock Recovery
ASPState Windows NT Service SQL Server Session state survives crashes/restarts Multiple FE machines point to a common state store
1.
Create web.config file in app vroot, and point it at state service machine:
<configuration> <system.web> <sessionState mode=StateServer stateConnectionString=tcpip=server:port /> </system.web> </configuration>
Session Summary
Very easy to implement Little or no coding required for most Enhances the reliability of your apps
ASP.NET Quickstart at
ASP.NET discussion lists For good best practice reference applications, please visit IBuySpy
http://www.IBuySpy.com
MS Press
Essential Resources for Developers
www.microsoft.com/mspress
Choose from Windows 2000, SQL Server 2000, Exchange 2000, Office 2000, .NET Framework, C#, VB.NET, ASP.NET, and XML
Training
Training Resources for IT Professionals
Introduction to ASP.NET
mcspreferral.microsoft.com/default.asp
Microsoft Certified Technical Education Centers (CTECs) are Microsofts premier partners for training services
MSDN
Essential Resources for Developers
Subscription Services Online Information Training & Events Print Publications Membership Programs Library, Professional, Universal Delivered via CD-ROM, DVD, Web MSDN Online, MSDN Flash
MSDN Training, Tech-Ed, PDC, Developer Days, MSDN/Onsite Events MSDN Magazine MSDN News MSDN User Groups
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
What Is MCSD?
Premium certification for professionals who design and develop custom business solutions It requires passing four exams to prove competency with Microsoft solution architecture, desktop applications, distributed application development, and development tools For more information about certification requirements, exams, and training options, visit www.microsoft.com/mcp
VS.NET 2003
Client, Server & Services enhancements Deep integration of solution orchestration Continued language innovation
2001
2002
2003
MSDN Subscriptions
Universal
Enterprise Developer
Enterprise
NEW
Professional
Professional
CT http://www.ctmsdev.net. ME http://www.mainebytes.com Feb 21 ASP.NET Tips and Tricks MA http://www.idevtech.com MA http://www.nevb.com MA http://www.bacom.com
MA http://www.starit.com/sughome First meeting Feb 4 7pm
http://www.nhdnug.com http://www.jjssystems.net First meeting Feb 11 6PM ASP.NET Tips and tricks Details coming
Do you have a very large shop? See Russ (rfustino@microsoft.com) or Bill (wheys@microsoft.com) about .NET Readiness offer.
A B B ASEA BROWN BOVERI INC AETNA CIGNA CVS E M C CORPORATION GETRONICS GILLETTE COMPANY INVENSYS PLC NORTHEAST UTILITIES PARTNERS HEALTH CARE INC RAYTHEON COMPANY STAPLES TEXTRON INC THOMSON CORPORATION TYCO INTERNATIONAL UNITED HEALTHCARE CORP UNITED TECHNOLOGIES CORPORATION And more
If youre an ISV.
For your development staff with a minimum size of 10 developers in over 300 pre-approved companies. One day onsite training (seminar format) Needs analysis 90 day MSDN Universal for 5 developers Contact rfustino@microsoft.com to see if your company is on the list.
Russ Fustino
Principal Technology Specialist Microsoft Corp
VS.NET Launch!
Feb 26 Cromwell CT 105186732 Feb 28 Waltham MA 9am-2pm 105186533 Feb 28 Waltham MA 3pm-8pm 105186549 Mar 5 Providence 105186566 Mar 13 Portland ME 105186557 Mar 14 Nashua NH - 105186565
Hands-on Expert VB.Net Training with Carl Franklin various cities in New England Take Carl Franklin's acclaimed VB.NET Master Class http://www.deeptraining.com
Session Credits