Download Web Parts - Microsoft

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
Microsoft Office System
UK Developers Conference
Radisson Edwardian, Heathrow
29th & 30th June 2005
Web Parts
Debugging, Deploying, And Best
Practices
Michael O’Donovan
Consultant
Microsoft UK
Agenda
Web Part Basics Review
Web Part Development and Debugging
Developing Web Parts
Advanced Web Part Topics
Work Items and Timeouts
IRuntimeFilter
Caching
ToolParts and ToolPanes
Page Customization
Deployment
Packages and Installer
Web Parts
Primary Platform Value of SharePoint
End-user Customization of Pages
In the Browser and in FrontPage
Standard Extensibility Point
Derive from
Microsoft.Sharepoint.WebPartPages.WebPart
Use Web Part Library Templates
Rendering Techniques
Direct Render Using Strings
HtmlTextWriter.Write(“…”)
HtmlTextWriter.WriteBeginTag(“…”)
Use ASP.NET HTML Primitives
HtmlTableClass
Delegating to ASP.NET Controls
Componentize Your Rendering Logic
Basic Demo
Debugging Web Parts
Methods
Direct
Attach to instance of W3WP.EXE
“Automatic”
Denote URL of a given Web Part Page as
application start page
Debugging Web Parts
(Continued)
Deploying to the GAC makes debugging
a little harder
Must be able to reach PDB file
Options
Deploy to the bin directory while debugging
Use manual installation
Tracing
System.Diagnostics.Trace
HttpContext.Trace
Web.Config Settings
Turn on debugging
<SharePoint> <SafeMode CallStack=“true" />
<system.web> <customErrors mode="Off" />
Change site’s Trust Level for the site
<system.web> <trust level="WSS_Minimal"
originUrl= ""/>
Also “WSS_Medium” or “Full”
Debugging Web Parts
Development Topologies
Single Machine
Shared Server
Development and
Server All on One
Box
Development
Machine Pushes
to Server
Windows Server
2003
Visual Studio.NET
2003
Windows XP
WSS
Visual Studio.NET
2003
SPS
Windows Server
2003
WSS
SPS
Single Machine
Pros
Simple
Speedy
Cons
Licensing
Time to setup
Every dev an admin
Hard to clean
Windows Server
2003
Visual Studio.NET
2003
WSS
SPS
Shared Server
Pros
Dev box is simpler
Cons
Two machines
Need scripts
Notes
Sharing a server is
not recommended
Virtual server per dev
Copy Microsoft.SharePoint.*
assemblies from
C:\Program Files\Common Files\
Microsoft Shared
\web server extensions\60\ISAPI
Windows XP
Visual Studio.NET
2003
Windows Server
2003
WSS
SPS
Advanced Web Part
Techniques
Work Items And Timeouts
Built-in support for asynchronous work
Allows other components to render
Scenarios
Data connections
RSS Fetching
Timeout renders based on
web.config setting
WorkItems
IRuntimeFilter
Allows you to filter which web parts run
Allows you to persist metadata on parts
Scoped to Virtual Server
NOTE: Portal uses this for
Audience Management
IRuntimeFilter
Caching
Web Part Framework
Per User or Web Part
In Memory or Serialised into Database
ASP .Net Cache Object
Share Cache across Part Instances
Enterprise Library Caching Application
Block
In HashTable
Survives Application Restarts
Caching
Configuration
How do I Store Central Configuration?
Do
Treat as .Net Server Control
Don’t
Use Web Part Resource File (XML)
Zone Customization
Zone Properties
AllowCustomization – Determines if the zone
web parts can be modified
AllowPersonalization – Determines if
personalization is allowed
FrameType – Determines the default
frame type
LockLayout – Determines if web parts can be
added, resized, or removed
ToolParts And Customization
ToolPart Controls
WebPart specifies list of supported toolparts
You derive from ToolPart
Set properties on the parent web part
Respond to Apply and Cancel
Custom ToolPane?
Rather hide ToolParts
ICustomizeToolPane
Best Practices
Handle All Exceptions
Implement IDesignTimeHtmlProvider
Interface
Make Properties User Friendly
Make Properties Searchable
Check Web Part Zone Properties When
Saving Changes
Best Practices
Check Permissions when Rendering
Validate Properties before Attempting
a Save
Specify Whether Your Web Part Can
Be Exported
HtmlEncode User Output
Create Custom Web Part Base Class
Web Parts And Upgrade
Changing Web Part Schema
AfterDeserialize event
Assembly Redirection in Web.Config
Distributing Web Parts
Distributing Web Parts
Manual
Copy required files into location
CAB files
Two-step process with STSADM
Stsadm –o addwppack –filename filename
Stsadm –o addwppack –name filename
MSI files
Install directly on each server
Deploying Web Parts
Method 1: Manual
Copy assembly DLL to either
/bin directory for a given IIS virtual server
(e.g., c:\inetpub\wwwroot\bin)
Global Assembly Cache
(e.g., c:\windows\assembly)
Copy DWP file to C:\Inetpub\wwwroot\wpcatalog
Copy resources to
For GAC-registered parts,
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\wpresources
For Web Parts in the /bin directory,
C:\Inetpub\wwwroot\wpresources
Deploying Web Parts
Method 1: Manual
Adjust web.config
Register as SafeControl
Select Code Access Security settings
Deploying Web Parts
Method 2: CAB File
CAB file should contain
Assembly DLL
DWP file(s)
Manifest.XML
Resource files (if needed)
CAB won’t contain
Code Access Security settings
Deploying Web Parts
Method 2: CAB File
Server-side object model has methods for
deploying such a CAB file
Deploy with STSADM.EXE
Located in C:\Program Files\Common
Files\Microsoft Shared\web server
extensions\60\BIN
Add it to your path
Stsadm –o addwppack –filename filename
[–globalinstall] [–force]
Deploying Web Parts
Method 3: MSI File via WPPackager
All of the features of CAB file deployment,
but with
Code Access Security support
Ability to uninstall via Control Panel
Get WPPackager.EXE from
http://msdn.microsoft.com/sharepoint
Add additional files to project for use
by WPPackager
Run WPPackager after project is built
Deploying Web Parts
Method 4: Standard MSI File
See the Site Definition Design and
Deployment Talk later today for
more details
Challenges
Per-virtual server settings and assemblies
MSI Custom Actions
Command Line Tools
Custom Online Web Part Gallery
Easily Deploy .DWP Files
Doesn’t Deploy the Assembly or
Resources
Custom Online Gallery
Not The Only Way
/_layouts/ Application
DataView Web Part
SmartPart
IFrame
PageViewer
What We Didn’t Cover
HtmlDesignerAttribute
CreateWebPartMenu
Connections
Web Part Services Component (WPSC)
Summary
Debugging Options
Advanced Techniques for Web Parts
Best Practices
Deployment Options
Discussion
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.