Microsoft Office System UK Developers Conference Radisson Edwardian, Heathrow 29 th 30 th June 2005

Preview:

DESCRIPTION

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

Citation preview

Microsoft Office SystemMicrosoft Office SystemUK Developers ConferenceUK Developers ConferenceRadisson Edwardian, HeathrowRadisson Edwardian, Heathrow2929thth & 30 & 30thth June 2005 June 2005

Web PartsDebugging, Deploying, And Best Practices

Michael O’DonovanConsultantMicrosoft UK

AgendaWeb Part Basics Review

Web Part Development and DebuggingDeveloping Web PartsAdvanced Web Part Topics

Work Items and TimeoutsIRuntimeFilterCachingToolParts and ToolPanesPage Customization

DeploymentPackages and Installer

Web PartsPrimary Platform Value of SharePoint

End-user Customization of PagesIn the Browser and in FrontPage

Standard Extensibility PointDerive from Microsoft.Sharepoint.WebPartPages.WebPartUse Web Part Library Templates

Rendering TechniquesDirect Render Using Strings

HtmlTextWriter.Write(“…”)HtmlTextWriter.WriteBeginTag(“…”)

Use ASP.NET HTML PrimitivesHtmlTableClass

Delegating to ASP.NET ControlsComponentize Your Rendering Logic

Basic Demo

Debugging Web PartsMethods

DirectAttach 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 harderMust be able to reach PDB fileOptions

Deploy to the bin directory while debuggingUse manual installation

TracingSystem.Diagnostics.TraceHttpContext.Trace

Web.Config SettingsTurn 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

Windows Server Windows Server 20032003

WSSWSS SPSSPS

Visual Visual Studio.NET Studio.NET

20032003

Windows XPWindows XPVisual Visual

Studio.NET Studio.NET 20032003

Windows Server Windows Server 20032003

WSSWSS SPSSPS

Single MachineSingle MachineDevelopment Development

and Server All on and Server All on One BoxOne Box

Development Development Machine Pushes Machine Pushes

to Serverto Server

Shared ServerShared Server

Single MachinePros

SimpleSpeedy

ConsLicensingTime to setupEvery dev an adminHard to clean

Windows Server Windows Server 20032003

WSSWSS SPSSPS

Visual Visual Studio.NET Studio.NET

20032003

Shared ServerPros

Dev box is simplerCons

Two machinesNeed scripts

NotesSharing a server is not recommendedVirtual server per devCopy Microsoft.SharePoint.*assemblies from C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\ISAPI

Windows XPWindows XPVisual Visual

Studio.NET Studio.NET 20032003

Windows Server Windows Server 20032003

WSSWSS SPSSPS

Advanced Web Part Techniques

Work Items And TimeoutsBuilt-in support for asynchronous workAllows other components to renderScenarios

Data connectionsRSS Fetching

Timeout renders based on web.config setting

WorkItems

IRuntimeFilterAllows you to filter which web parts run Allows you to persist metadata on partsScoped to Virtual Server

NOTE: Portal uses this for Audience Management

IRuntimeFilter

CachingWeb Part Framework

Per User or Web PartIn Memory or Serialised into Database

ASP .Net Cache ObjectShare Cache across Part Instances

Enterprise Library Caching Application Block

In HashTableSurvives Application Restarts

Caching

ConfigurationHow do I Store Central Configuration?Do

Treat as .Net Server ControlDon’t

Use Web Part Resource File (XML)

Zone CustomizationZone Properties

AllowCustomization – Determines if the zone web parts can be modifiedAllowPersonalization – Determines if personalization is allowedFrameType – Determines the default frame typeLockLayout – Determines if web parts can be added, resized, or removed

ToolParts And Customization

ToolPart ControlsWebPart specifies list of supported toolparts

You derive from ToolPartSet properties on the parent web partRespond to Apply and Cancel

Custom ToolPane?Rather hide ToolPartsICustomizeToolPane

Best PracticesHandle All ExceptionsImplement IDesignTimeHtmlProvider InterfaceMake Properties User FriendlyMake Properties SearchableCheck Web Part Zone Properties When Saving Changes

Best PracticesCheck Permissions when RenderingValidate Properties before Attempting

a SaveSpecify Whether Your Web Part Can Be ExportedHtmlEncode User OutputCreate Custom Web Part Base Class

Web Parts And UpgradeChanging Web Part Schema

AfterDeserialize eventAssembly Redirection in Web.Config

Distributing Web Parts

Distributing Web PartsManual

Copy required files into locationCAB files

Two-step process with STSADMStsadm –o addwppack –filename filenameStsadm –o addwppack –name filename

MSI filesInstall directly on each server

Deploying Web PartsMethod 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\wpcatalogCopy resources to

For GAC-registered parts,C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresourcesFor Web Parts in the /bin directory,C:\Inetpub\wwwroot\wpresources

Deploying Web PartsMethod 1: Manual

Adjust web.configRegister as SafeControlSelect Code Access Security settings

Deploying Web PartsMethod 2: CAB File

CAB file should containAssembly DLLDWP file(s)Manifest.XMLResource files (if needed)

CAB won’t containCode Access Security settings

Deploying Web PartsMethod 2: CAB File

Server-side object model has methods for deploying such a CAB fileDeploy with STSADM.EXE

Located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BINAdd it to your pathStsadm –o addwppack –filename filename

[–globalinstall] [–force]

Deploying Web PartsMethod 3: MSI File via WPPackager

All of the features of CAB file deployment, but with

Code Access Security supportAbility to uninstall via Control Panel

Get WPPackager.EXE fromhttp://msdn.microsoft.com/sharepointAdd additional files to project for use by WPPackagerRun WPPackager after project is built

Deploying Web PartsMethod 4: Standard MSI File

See the Site Definition Design and Deployment Talk later today for more detailsChallenges

Per-virtual server settings and assemblies

MSI Custom ActionsCommand Line Tools

Custom Online Web Part Gallery

Easily Deploy .DWP FilesDoesn’t Deploy the Assembly or Resources

Custom Online Gallery

Not The Only Way/_layouts/ ApplicationDataView Web PartSmartPartIFrame

PageViewer

What We Didn’t CoverHtmlDesignerAttributeCreateWebPartMenuConnectionsWeb Part Services Component (WPSC)

SummaryDebugging OptionsAdvanced Techniques for Web PartsBest PracticesDeployment 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.

Recommended