too ll shed asp net tips and tricks
TRANSCRIPT
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
1/62
ASP.NET Tips and Tricks
Russ FustinoMicrosoft Corporation
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
2/62
What we will cover
Development Tips and Tricks Error Handling Tips and Tricks
Production Tips and Tricks
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
3/62
Session Prerequisites
Level 300
ASP
Basic knowledge of ASP.NET
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
4/62
Agenda
Development Tips and Tricks
Error Handling Tips and Tricks
Production Tips and Tricks
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
5/62
Development Tips And TricksFile upload
ASP.NET provides built-in file upload support No posting acceptor required
No third party components required
Accessible through two APIs: Request.Files collection
server control
HttpPostedFile Object:
HttpPostedFile.InputStream HttpPostedFile.ContentType
HttpPostedFile.FileName
HttpPostedFile.SaveAs(fileLocation)
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
6/62
Sub Btn_Click(Sender as Object, E as EventArgs)UploadFile.PostedFile.SaveAs("c:\foo.txt")
End Sub
Select File To Upload:
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
7/62
Demonstration 1File Upload
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
8/62
File system is not the only option
Example: Storing within SQL
Access uploaded file asbyte 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 thenwrites binary array back to client
Development Tips And TricksRicher file upload
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
9/62
Demonstration 2File Upload With SQL
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
10/62
Rich server image generation
Additionally supports resizing & cropping
Overlays on top of existing images
Read/Write Any Standard IO Stream
System.Drawing
Dynamically generate GIFs/JPGs from .aspx
Set ContentType appropriately
Optionally output cache results
Development Tips And TricksImage generation
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
11/62
Demonstration 3Image Generation
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
12/62
ASP.NET
Enables output of XML
Enables optional XSL/T transform of XML
Binding options File system
Database item
Built-in caching Ensure efficient re-use
Improves performance
Development Tips And TricksASP.NET XML Server Control
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
13/62
Development Tips And Tricks file sample
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
14/62
Demonstration 4Static XML
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
15/62
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 = XmlDocEnd Sub
Development Tips And Tricks data sample
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
16/62
Demonstration 5Dynamically Bind XML
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
17/62
Application specific settings
Stored inweb.config files
Enables devs to avoid hard-coding them
Administrators can later change them
Examples:
Database Connection String MSMQ Queue Servers
File Locations
Development Tips And TricksApp settings
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
18/62
1. Create web.config file in app vroot:
2. To return value:
Configuration.AppSettings(dsn)
Development Tips And TricksApp settings steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
19/62
Demonstration 6Application Settings
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
20/62
Session State no longer requires clientcookie support for SessionID
Can optionally track SessionID in URL
Requires no code changes to app
All relative links continue to work
Development Tips And TricksCookieless sessions
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
21/62
1. Create web.config file in app vroot
2. Add following text:
Development Tips And TricksCookieless sessions steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
22/62
Eliminates browser flicker/scrolling onbrowser navigation
Smooth client UI but with server code
Automatic down-level for non-IE browsers
No client code changes required
Alternatively set inweb.config file
Development Tips And TricksSmart navigation
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
23/62
Agenda
Development Tips and Tricks
Error Handling Tips and Tricks
Production Tips and Tricks
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
24/62
ASP.NET supports page and app tracing Easy way to include debug statements
No more messy Response.Write() calls!
Great way to collect request details
Server control tree
Server variables, headers, cookies
Form/Querystring parameters
Error Handling Tips And TricksPage tracing
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
25/62
1. Add trace directive at top of page
2. Add trace calls throughout pageTrace.Write(Button Clicked)
Trace.Warn(Value: + value)
3. Access page from browser
Error Handling Tips And TricksPage tracing steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
26/62
Demonstration 7Page Tracing
E H dli Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
27/62
1. Create web.config file in app vroot:
2. Access tracing URL within app http://localhost/approot/Trace.axd
Error Handling Tips And TricksApplication tracing steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
28/62
Demonstration 8Application Tracing
E H dli Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
29/62
.NET provides unified error architecture Runtime errors done using exceptions
Full call stack information available w/ errors
Can catch/handle/throw exceptions in any.NET Language (including VB)
ASP.NET also provides declarative
application custom error handling Enable programmatic logging of problems
Automatically redirect users to error pagewhen unhandled exceptions occur
Error Handling Tips And TricksError handling
E H dli Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
30/62
Global application event raised ifunhandled exception occurs
Provides access to current Request
Provides access to Exception object Enables developer to log/track errors
Cool Tip:
Use new EventLog class to write customevents to log when errors occur
Use new SmtpMail class to send email toadministrators
Error Handling Tips And TricksApplication_Error
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
31/62
Demonstration 9Writing to NT Event Log
E H dli Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
32/62
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
33/62
Enable easy way to hide errors fromend-users visiting a site
No ugly exception error messages
Enables you to display a pretty site underrepair page of your design
Custom Errors configured within an
application web.config configuration file Can be configured per status code number
Can be configured to only display remotely
Error Handling Tips And TricksCustom errors
E H dli Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
34/62
1. Create web.config file in app vroot:
Error Handling Tips And TricksCustom error page steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
35/62
Demonstration 10Custom Errors
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
36/62
Agenda
Development Tips and Tricks
Error Handling Tips and Tricks
Production Tips and Tricks
P d ti Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
37/62
Per Application Performance Counters Enable easily monitoring of individual
ASP.NET applications
Custom Performance Counters APIs
Now possible to publish unique application-specific performance data
Great for real-time application monitoring Example: total orders, orders/sec
Production Tips And TricksPerformance counters
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
38/62
Demonstration 11Performance Counters
P d ti Ti A d T i k
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
39/62
ASP.NET runs code in an externalworker process aspnet_wp.exe
Automatic Crash Recovery
Automatic Memory Leak Recovery Automatic Deadlock Recovery
Can also proactively configure worker
process to reset itself proactively Timer based
Request based
Production Tips And TricksProcess model recovery
Production Tips And Tricks
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
40/62
Session State can now be externalfrom ASP.NET Worker Process
ASPState Windows NT Service
SQL Server
Big reliability wins
Session state survives crashes/restarts
Enables Web farm deployment Multiple FE machines point to a common
state store
Production Tips And TricksReliable session state
Production Tips And Tricks
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
41/62
1. Start ASP State Service on a machine net start aspnet_state
2. Create web.config file in app vroot,
and point it at state service machine:
Production Tips And TricksExternal session state steps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
42/62
Session Summary
Very easy to implement Little or no coding required for most
Enhances the reliability of your apps
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
43/62
For More Information
MSDN Web site at msdn.microsoft.com
ASP.NET Quickstart at
http://www.asp.net 900+ samples that can be run online
ASP.NET discussion lists
For good best practice referenceapplications, please visit IBuySpy http://www.IBuySpy.com
S
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
44/62
MS PressEssential Resources for Developers
Find out other titles from MS Press books at
www.microsoft.com/mspressChoose from Windows 2000, SQL Server 2000, Exchange 2000, Office
2000, .NET Framework, C#, VB.NET, ASP.NET, and XML
T i i
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
45/62
TrainingTraining Resources for IT Professionals
Introduction to ASP.NET
Course # 2063
Available: Now
To locate a training provider for this course, please access
mcspreferral.microsoft.com/default.aspMicrosoft Certified Technical Education Centers (CTECs)
are Microsofts premier partners for training services
MSDN
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
46/62
Training &Events
MSDN Training, Tech-Ed, PDC,Developer Days, MSDN/Onsite Events
MSDNEssential Resources for Developers
SubscriptionServices
OnlineInformation
MembershipPrograms
PrintPublications
Library, Professional, UniversalDelivered via CD-ROM, DVD, Web
MSDN Online, MSDN Flash
MSDN User Groups
MSDN MagazineMSDN News
Wh C I G MSDN?
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
47/62
Where Can I Get MSDN? Visit MSDN Online at
msdn.microsoft.com
Register for the MSDN Flash EmailNewsletter at
msdn.microsoft.com/flash
Become an MSDN CD Subscriber atmsdn.microsoft.com/subscriptions
MSDN online seminars
msdn.microsoft.com/training/seminars
Attend More MSDN Events
B A Mi ft
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
48/62
Become A MicrosoftCertified Solution Developer What Is MCSD?
Premium certification for professionals who designand develop custom business solutions
How Do I attain MCSD Certification? It requires passing four exams to prove
competency with Microsoft solution architecture,desktop applications, distributed applicationdevelopment, and development tools
Where Do I Get More Information? For more information about certification
requirements, exams, and training options,visit www.microsoft.com/mcp
Mi ft D l R d
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
49/62
Microsoft Developer RoadmapProducts, Technologies, Subscriptions
20022001
Visual Studio .NET 2002 VS.NET 2003
2003
Client, Server &Services enhancements
Deep integration ofsolution orchestration
Continued languageinnovation
Base features for XMLWeb services & mobileapp development
Visual Studio 6.0
Enterprise lifecycletools
Development teams
Design XML Webservices
Provide architecturalguidance to teams
New product line nowmaps to all levels ofVisual Studio .NET
SOAP Toolkit 2.0 J#, Devices
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
50/62
MSDN For Everyone
Enterprise Architect
Enterprise Developer
VB, C++, C#Standard
Professional
Visual Studio .NET
Universal
Library
Operating Systems
MSDN Subscriptions
Professional
EnterpriseNEW
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
51/62
.NET Developer SIGS(CT, MA and ME) msdn.microsoft.com/usergroups
4th Tuesday of each month (CT) CT http://www.ctmsdev.net.
2nd Wed of each month (MA and ME) ME http://www.mainebytes.com Feb 21 ASP.NET Tips and Tricks
MA http://www.idevtech.com
VB.NET 1st Thursday (MA) MA http://www.nevb.com
BACOM 2nd Monday (MA)
MA http://www.bacom.com
Share Point Server (MA) 4th Tuesday
MAhttp://www.starit.com/sughome First meeting Feb 4 7pm
NET Developer SIGS
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
52/62
.NET Developer SIGS(NH, VT, RI) msdn.microsoft.com/usergroups
.NET user groups in NH http://www.nhdnug.com
http://www.jjssystems.net
.NET user group in Burlington VT First meeting Feb 11 6PM ASP.NET Tips and
tricks
.Net user group for RI
Details coming
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
53/62
Do you have a very large shop?
See Russ([email protected])
orBill ([email protected])about .NET Readiness offer.
PARTNERS HEALTH CARE INCRAYTHEON COMPANYSTAPLESTEXTRON INCTHOMSON CORPORATIONTYCO INTERNATIONALUNITED HEALTHCARE CORPUNITED TECHNOLOGIES
CORPORATIONAnd more
A B B ASEA BROWN BOVERI INCAETNACIGNAC V SE M C CORPORATIONGETRONICSGILLETTE COMPANYINVENSYS PLCNORTHEAST UTILITIES
mailto:[email protected]:[email protected]:[email protected]:[email protected] -
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
54/62
If youre an ISV.
email Joe Stagner [email protected] and introduceyourself!
mailto:[email protected]:[email protected] -
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
55/62
.NET Blitz program
For your development staff with a minimum sizeof 10 developers in over 300pre-approved companies.
One day onsite training (seminar format)
Needs analysis
90 day MSDN Universal for 5 developers
Contact [email protected] to see if your
company is on the list.
mailto:[email protected]:[email protected] -
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
56/62
Russ Tool Shed9am-4pm
To be scheduled soon!
Signup for the newsletter above for details.
Russ FustinoPrincipal Technology SpecialistMicrosoft Corp
www.microsoft.com/
/usa/newengland/
russtoolshed
S
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
57/62
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
Live Webcast Events:
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
58/62
Live Webcast Events:http://www.microsoft.com/usa/webcasts/upcoming/
Architecting Web ServicesJanuary 14, 2002 , 3pmMicrosoft Webcast Presents: XML Basics January16, 2002, 3pm
.NET Class Libraries From A to ZJanuary 22, 2002, 2pm
Understanding Visual InheritanceJan 23, 2002 3pm
Advanced Web Services Using ASP .NETJanuary29, 2002, 2PMWebservices 101January 30, 2002 3pmAdvanced XML/XSLFebruary 1, 2002 3:30pmHow To Build Mobile Solutions Using theMicrosoft Mobile Internet Toolkit February 5, 20022pm
Caching ASP.NET Application Settings February 6,2002, 3pmBuilding a .NET Mobile SolutionFebruary 13, 2002 3pm
Live Webcast Events:
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
59/62
Live Webcast Events:http://www.microsoft.com/usa/webcasts/upcoming/
XML and Web Enabling LegacyApplications Using BizTalk Server2000 February 19, 2002 2pmAdvanced Webpart DevelopmentFebruary 20, 2002 3pm
How To Develop AsynchronousApplications with .NET FrameworkFebruary 26, 2002 2pm
Introducing .NET Alerts February 27, 2002 3pmPart 1: Architecting an Applicationusing the .NET Framework March 5, 2002 2pm
Part 2: Building a .NET ApplicationMarch 12, 2002 2pmASP .NET - Tips and Tricks March 19, 2002 2pm
Tool Shed Code and PowerPoint
-
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
60/62
Tool Shed Code and PowerPointslides
PowerPoint slides:www.microsoft.com/usa/newengland/
russtoolshed Code: http://www.franklins.net/~russ
Carl Franklins
http://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.franklins.net/~russhttp://www.franklins.net/~russhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshedhttp://www.microsoft.com/usa/newengland/%0Brusstoolshed -
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
61/62
Carl Franklin s
VB.NET Master Class
Hands-on Expert VB.Net Training withCarl Franklin various cities in New England
Take Carl Franklin's acclaimed VB.NET
Master Class http://www.deeptraining.com
http://www.franklins.net/vbnetmc.asphttp://www.franklins.net/vbnetmc.asp -
7/31/2019 Too Ll Shed ASP Net Tips and Tricks
62/62