sharepoint development for asp net developers
DESCRIPTION
Slides given for my talk about an introduction to SharePoint development at Oklahoma City Developer Group - December 2008.TRANSCRIPT
SharePoint Development for ASP.NET Developers
Presenter: Corey RothEnterprise ConsultantStonebridge
Blog: www.dotnetmafia.com
Corey Roth
Consultant for Stonebridge Worked in Consumer Electronics, Travel, Advertising,
and Energy industries Currently doing MOSS development specializing in
Enterprise Search and ECM OSU Graduate Microsoft Award for Customer Excellence (ACE)
Winner E-mail: [email protected] Blog: www.dotnetmafia.com (mirrored on
sharepointblogs.com)
SharePoint 3.0 or MOSS 2007?
SharePoint 3.0 (WSS) is included with Windows Server
MOSS extends the features of WSS MOSS requires a separate license MOSS includes Business Data Catalog
(BDC), Enterprise Seach, Excel Services, My Sites, KPI dashboards, People Search, Forms Services, etc.
Environment
Virtualization – Windows Server, WSS or MOSS, and Visual Studio installed
SharePoint on Remote Server – Requires remote debugging
SharePoint on Vista – Works but not supported
SharePoint Basics
Farm – Represents the collection of servers of the SharePoint deployment
Web Applications – Typically one or more of these maps to a web site in IIS (i.e.: Port 80)
Site Collection (SPSite) – Will have at least one. Groups sites together
Site (SPWeb) – Represents a site or subsite in a Site Collection. Contains pages, lists, etc.
Feature – Allows code and SharePoint changes to occur at the click of a button
What’s different about SharePoint development? Environment Deployment Pages and Sites Must deploy DLLs to GAC or use Code
Access Security if deploying to bin folder User controls must be hosted by a web part
12 Hive Location of most key SharePoint files: C:\
Program Files\Common Files\microsoft shared\Web Server Extensions\12
Folder Description
CONFIGContains partial trust configuration files
ISAPIBinaries and SharePoint Web Services
LOGSError Logs (look here first when you get a strange error)
TEMPLATE\CONTROLTEMPLATES User Controls
TEMPLATE\FEATURESSharePoint Features (turns functionality on and off)
TEMPLATE\IMAGES MainImages Folder
TEMPLATE\LAYOUTS Pages and Styles
12 Hive (Continued)
Folder Description
TEMPLATE\SiteTemplatesDefinitions avaiable for deploying new sites
TEMPLATE\THEMESUsed to create custom themes in SharePoint
TEMPLATE\XMLContains XSDs for any XML used with SharePoint
Building a User Control with Visual Studio Web Application Project Reference Microsoft.SharePoint.dll Must be registered as safe for SharePoint to
execute Typically deployed to bin folder using Code
Access Security Controls are typically deployed to the
CONTROLTEMPLATES folder in the 12 hive. _ControlTemplates Virtual Directory Complete instructions are on my blog
SafeControls
SharePoint won’t execute a web part or user control unless it knows it is safe
Declare an assembly and namespace safe in web.config
SafeControls element Can be automated using a solution package
(.wsp)
SharePoint API
SPContext – Used to get reference to the current site or site collection
All uses of SPSite or SPWeb must be disposed (use a using statement)
Most collections do not have an “Exists” method
Most objects require a call to .Update to save any changes made
Some API calls require elevated security – Pass a delegate to RunWithElevatedPrivleges
Demo
Deployment Options
Manually copy binaries, feature files, pages, and controls to appropriate folders on SharePoint server
Create a Feature – Would still have to manually copy files
Create a Solution Package (.wsp) – A cab file that contains a manfiest telling SharePoint how to deploy
What the Solution Package does…
Backs up your web.config Changes the trust element to WSS_Custom
in web.config Backs up trust configuration file –
wss_minimaltrust.config becomes wss_custom_wss_minimaltrust.config
Changes the path to the trust configuration file in the web.config <trustLevel> element
Adds code access security settings from manifest.xml
More information on my blog
Demo
Building and Deploying a Web Part
Deploys similarly to a user control .webpart (or .dwp) file tells SharePoint where
to find the web part’s code Use a feature to add the web part to the
gallery Complete instructions can be found on my
blog
Demo
Feature Receivers
Feature Receivers allow you to execute code when a feature is Installed, Uninstalled, Activated, or Deactivated
Create a class that inherits from SPFeatureReceiver
Configured in Feature.xml SPFeatureProperties.Feature.Parent
contains reference to SPWeb or SPSite object depending on scope of feature (must be cast)
Demo
ReferencesDot Net Mafia Bloghttp://www.dotnetmafia.com
Office SharePoint Server SDKhttp://msdn2.microsoft.com/en-us/library/ms550992.aspx
STSDevhttp://www.codeplex.com/stsdev
SharePoint Blogshttp://www.sharepointblogs.com
Questions?
Thanks
Corey [email protected] www.dotnetmafia.com