<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DevExpertise &#187; WSS</title>
	<atom:link href="http://www.devexpertise.com/tag/wss/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devexpertise.com</link>
	<description>Practical tips and tricks for all things .NET, SharePoint, Silverlight, InfoPath, and general application development.</description>
	<lastBuildDate>Wed, 12 May 2010 14:32:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting the Welcome Page in WSS 3.0</title>
		<link>http://www.devexpertise.com/2009/02/02/setting-the-welcome-page-in-wss-30/</link>
		<comments>http://www.devexpertise.com/2009/02/02/setting-the-welcome-page-in-wss-30/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 00:27:31 +0000</pubDate>
		<dc:creator>DevExpert</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://www.devexpertise.com/?p=4</guid>
		<description><![CDATA[Whenever someone navigates to your SharePoint site without a specific page specified in the URL, such as http://fakeserver/sites/fakesite/, SharePoint navigates you to the site’s welcome page, typically default.aspx.&#160; MOSS publishing sites provide the ability to change this by going to Site Settings &#62; Welcome Page, and changing the page.&#160; What about team sites, or WSS [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever someone navigates to your SharePoint site without a specific page specified in the URL, such as http://fakeserver/sites/fakesite/, SharePoint navigates you to the site’s welcome page, typically default.aspx.&#160; MOSS publishing sites provide the ability to change this by going to Site Settings &gt; Welcome Page, and changing the page.&#160; What about team sites, or WSS sites?&#160; There is no way to modify the welcome page through the UI.&#160; One could open SharePoint Designer and do it that way, but this isn’t ideal if you don’t have a license for SPD.&#160; I’ll be describing another approach in this post that leverages the Object Model, and I’m even providing a complete SharePoint solution (WSP) file that you can install and activate on any WSS site!</p>
<p>First, let’s take a look at the code snippet to make this happen.&#160; The SPFolder object has a property called <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');" target="_blank">WelcomePage</a>, and all that is needed is to set this property on the SPWeb’s RootFolder:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">using </span>(<span style="color: #2b91af">SPSite </span>siteCollection = <span style="color: blue">new </span><span style="color: #2b91af">SPSite</span>(<span style="color: #a31515"><a href="http://server/sites/sandbox" onclick="javascript:pageTracker._trackPageview('/outbound/article/');">http://server/sites/sandbox</a></span>)) {
    <span style="color: blue">using </span>(<span style="color: #2b91af">SPWeb </span>site = siteCollection.RootWeb) {
        <span style="color: #2b91af">SPFolder </span>rootFolder = site.RootFolder;
        rootFolder.WelcomePage = <span style="color: #a31515">&quot;Pages/home.aspx&quot;</span>;
        rootFolder.Update();
    }
}</pre>
</div>
<p>
  <br />Now, whenever I hit http://server/sites/sandbox, I am directed to my custom Home.aspx page in my Pages document library:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image7.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="450" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb7.png" width="690" border="0" /></a> </p>
<p>
  <br />Woo hoo!&#160; If I click on the Sandbox title or its icon, or even in the breadcrumb, I’m directed here, because it’s to the site’s root URL, not to a specific page.&#160; But what if I click the Home link on the top navigation bar? It takes me to my original default.aspx page, which defeats the purpose.&#160; To fix this, we need to add the following lines of code:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: #2b91af">SPNavigationNode </span>homeNode = site.Navigation.TopNavigationBar.Navigation.Home;
homeNode = site.Navigation.TopNavigationBar[0];
homeNode.Url = <span style="color: #2b91af">SPUrlUtility</span>.CombineUrl(site.Url, <span style="color: #a31515">&quot;Pages/home.aspx&quot;</span>);
homeNode.Update();</pre>
</div>
<p>
  <br />Now, no matter what I click to bring me back to the root page, I’m directed to my home.aspx page.&#160; Who said the Welcome Page was a MOSS-only feature?</p>
<p>&#160;</p>
<p><strong>SharePoint Solution</strong> </p>
<p>It doesn’t make sense to expect an end user to run a console app or write custom code to do this.&#160; It’s possible to do this via SharePoint designer too, but what if they don’t have it?&#160; It makes a lot more sense to present this to users in the browser, exactly like a MOSS publishing site.&#160; To provide this functionality, it’s just as simple as creating a custom LAYOUTS page and a solution package that can be used to deploy and install it.&#160; </p>
<p>First, we create the file-system structure in the Visual Studio solution:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image9.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="229" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb8.png" width="332" border="0" /></a> </p>
<p>
  <br />Next, define the feature:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: maroon">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue">?&gt;
&lt;</span><span style="color: maroon">Feature
  </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">2D3BDDCF-E6A4-4110-922C-70E79652C6B9</span>&quot;
  <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise Welcome Page Feature</span>&quot;
  <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Contains the page and shortcuts to change a site's welcome page</span>&quot;
  <span style="color: red">Version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0.0.0</span>&quot;
  <span style="color: red">Scope</span><span style="color: blue">=</span>&quot;<span style="color: blue">Site</span>&quot;
  <span style="color: red">Hidden</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;
  <span style="color: red">ImageUrl</span><span style="color: blue">=</span>&quot;<span style="color: blue">DevExpertise.WelcomePage\devExpertiseFeatureLogo.png</span>&quot;
  <span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: maroon">ElementManifests</span><span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">ElementManifest </span><span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">CustomActions.xml</span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: maroon">ElementManifests</span><span style="color: blue">&gt;
&lt;/</span><span style="color: maroon">Feature</span><span style="color: blue">&gt;</span></pre>
</div>
<p>
  <br />The custom action should be defined to add a link to the Look &amp; Feel category (GroupId=”Customization”):</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: maroon">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot; <span style="color: blue">?&gt;
&lt;</span><span style="color: maroon">Elements </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>&quot;<span style="color: blue">&gt;
  &lt;</span><span style="color: maroon">CustomAction
    </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">UserGroupAdminLinkForSettings</span>&quot;
    <span style="color: red">GroupId</span><span style="color: blue">=</span>&quot;<span style="color: blue">Customization</span>&quot;
    <span style="color: red">Location</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.SharePoint.SiteSettings</span>&quot;
    <span style="color: red">RequireSiteAdministrator</span><span style="color: blue">=</span>&quot;<span style="color: blue">TRUE</span>&quot;
    <span style="color: red">Sequence</span><span style="color: blue">=</span>&quot;<span style="color: blue">120</span>&quot;
    <span style="color: red">Title</span><span style="color: blue">=</span>&quot;<span style="color: blue">Welcome Page</span>&quot;<span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">UrlAction </span><span style="color: red">Url</span><span style="color: blue">=</span>&quot;<span style="color: blue">_layouts/DevExpertise.WelcomePage/WelcomePage.aspx</span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: maroon">CustomAction</span><span style="color: blue">&gt;
&lt;/</span><span style="color: maroon">Elements</span><span style="color: blue">&gt;
</span></pre>
</div>
<p>
  <br />Package up your solution using <a href="http://www.codeplex.com/wspbuilder" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.codeplex.com');" target="_blank">WSPBuilder</a> and deploy it.&#160; After it’s deployed and activated on the site collection, I’m presented with a Welcome Page link on each and every sub site in the site collection, allowing me to set the welcome page for each site:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image10.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="224" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb9.png" width="208" border="0" /></a> </p>
<p>
  <br />Clicking the link will navigate to the custom LAYOUTS page I created:</p>
<p><a href="http://www.devexpertise.com/wp-content/uploads/2009/02/image12.png" ><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="485" alt="image" src="http://www.devexpertise.com/wp-content/uploads/2009/02/image-thumb10.png" width="709" border="0" /></a></p>
</p>
</p>
<p>
  <br />This is a great method for providing functionality that may be missing from the user interface.&#160; Once you master the steps required to create a LAYOUTS page (which I’ll be covering step-by-step in a future post), and master creating custom actions, the possibilities to extend and enhance your SharePoint site are endless.</p>
<p>I’ve included this solution package for you to deploy and use.&#160; As always, the code is as-is and without warranty, so if it doesn’t work – fix it! </p>
<p></p>
</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:8925b775-a0c2-48dd-9aaa-c6a3631ca7b3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p>Download Solution: <a href="http://www.devexpertise.com/wp-content/uploads/2009/02/devexpertisewelcomepage3.zip" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2009/02/devexpertisewelcomepage3.zip');" target="_blank">DevExpertise.WelcomePage.zip</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.devexpertise.com/2009/02/02/setting-the-welcome-page-in-wss-30/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
