Enable anonymous access to SharePoint 2013 – Part 1- Configure Web Application and SiteCollection

3. April 2014 12:59 by arnoldbo in SharePoint  //  Tags: ,   //   Comments

This blog post describes how you can enable anonymous access to your SharePoint environment, anonymous access is often used when creating public facing websites.

Update 04/11/2014 Added FAQ item open office documents for anonymous users.

Part 1: Configure Web Application and Site Collection – This Article

Part 2: Configure for CSOM and REST Api

Preparing the Web Application

On Web Application level your IIS sites needs to know that it needs to accept anonymous requests, enabling anonymous access in SharePoint will enable the Anonymous Authentication provider for the Web Application across the Farm.

Configure anonymous access

Central Admin

  • Login to Central Administration
  • Open Manage Web applications
  • Select the Web Application where you want to enable Anonymous Access for
  • Click on Authentication Providers in the ribbon and select the Zone
  • Select Enable Anonymous Access, then click Save to update all IIS instances in the Farm

 

PowerShell

#Enable anonymous access on webapplication
Write-Host -ForegroundColor White " - Set Anonymous access to webapplication"
$WebApp = Get-SPWebApplication -Identity http://root.contoso.com
#In this sample anonymous access is set to the default zone
$Zone=[Microsoft.SharePoint.Administration.SPUrlZone]::Default 
$i = $WebApp.IisSettings[$Zone]
if($i.AllowAnonymous -ne $true){
   $i.AllowAnonymous = $true
   $WebApp.Update()
   $WebApp.ProvisionGlobally()
}else{
   Write-Host -ForegroundColor White " - Anonymous access already set"
}

Client callable settings

By default not all operation are allowed for anonymous users, some operations are blocked

With PowerShell you can get a list of restricted types with the following PowerShell code:

$wa = Get-SPWebApplication -Identity "http://root.contoso.com"
$wa.ClientCallableSettings.AnonymousRestrictedTypes

 

Most interesting restricted type is the method GetItems on SPList, this means that it is not possible to retrieve List items with the client object model.

Enable restricted types

With PowerShell it is possible to remove the restrictions of the types that you want to allow anonymous users to use.

Write-Host "Remove Anonymous restricted type GetItems."
$webApp = Get-SPWebApplication -Identity $webApplication
$webApp.ClientCallableSettings.AnonymousRestrictedTypes.Remove( [Microsoft.SharePoint.SPList],"GetItems")
$webApp.Update()

 

Configure site collection for anonymous access

After anonymous access is enabled on the Web Application the site collection needs to be configured for anonymous access, anonymous access can be set through the user interface or by PowerShell.

Site Settings

  • Open Site Settings on the root web of the site collection
  • Open Site Permissions
  • Select Anonymous Access in the ribbon 
  • Select Entire Website and click Ok

PowerShell

The same settings can be set with the following PowerShell Script

$siteCollectionUrl = "http://anonymous.contoso.com"
$web = Get-SPWeb $siteCollectionUrl
$web.AnonymousState = [Microsoft.SharePoint.SPWeb+WebAnonymousState]::Enabled
$web.AnonymousPermMask64 = "Open, ViewPages, ViewListItems"
$web.Update()

Be aware that anonymous settings has to be set on all sites and lists where you need anonymous users to have access, pay attention to broken security inheritance!

It is now possible to access the site collection anonymous, the following blog post will focus on accessing the site collection anonymous with the Javascript Object Model (JSOM) and REST Api Index.

FAQ

Q: How to open Office documents for anonymous users without getting an 401 Unauthorized exception

A: Add the “OpenItems” permission to the default AnonymousPermMask64, there is a blog post from Anthony with a PowerShell script to update the permission mask.

On demand conversion with Word automation services

5. March 2013 13:39 by arnoldbo in SharePoint  //  Tags: , ,   //   Comments

Introduction

In SharePoint 2010 word automation services was introduced the service could be used to do a lot of batch conversion tasks. The implementation had a couple of drawback’s:

  • File generation has to wait for the timer job to execute
  • Can only handle files in SharePoint
  • No feedback when job is done in an easy way

With SharePoint 2013 it is now possible to:

  • Convert documents on the fly
  • Source file doesn’t need to exist in SharePoint
  • Save converted files anywhere you want

The following TechNet article describes the architecture of on demand file conversion: What's new in Word Automation Services for developers

Code download

Download solution

Solution

With the following code examples I want to demonstrate how you can convert files on demand, in the example an word document can be converted on demand to a PDF document.

In the solution the following items are created:

  • Custom action with an Edit Control block
  • Application page were the conversion takes place

Custom action

The custom action should be added to the EditControlBlock and only be available for word documents.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Create custom action in Visual studio:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
       Id="E0648444-7D5A-4917-875D-C594E4266282.CustomAction"
       RegistrationType="FileType"
       RegistrationId="docx"
       Location="EditControlBlock"
       Sequence="10001"
       Title="Convert to PDF"
       ImageUrl="/_layouts/15/images/icpdf.png">
    <UrlAction Url="javascript:OpenPopUpPageWithTitle('{SiteUrl}/_layouts/Vivens.SP2013.WordServices/WordAutomationConverter.aspx?
      ListId={ListId}&amp;ItemId={ItemId}&amp;ItemUrl={ItemUrl}', RefreshOnDialogClose, 600, 400,'Convert to PDF')"/>
  </CustomAction>
</Elements>

 

Application page

The application page is opened in a dialog window and from this page it is possible to initiate the on demand conversion.

WordAutomationConverter.aspx

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Panel id="pnlConversion" runat="server">
        <asp:Label ID="lblInputItem" runat="server" Text="Label"></asp:Label>

        <asp:Button ID="btnConvertSharePointFile" runat="server" Text="Save document as PDF" OnClick="btnConvertSharePointFile_Click" />
        <asp:Button ID="btnDownloadAsPdf" runat="server" Text="Download file as PDF" OnClick="btnDownloadAsPdf_Click" />
    </asp:Panel>
    <asp:Panel ID="pnlCompleted" runat="server" Visible="false">
        <asp:Label ID="lblConvertStatus" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="btnReturnToList" runat="server" Text="Return to list" OnClick="btnReturnToList_Click"  />
    </asp:Panel>

</asp:Content>

WordAutomationConverter.aspx.cs

Read the input file in the Page_Load event

        protected void Page_Load(object sender, EventArgs e)
        {
            // Only set up the values the first time the page is loaded
            if (!IsPostBack)
            {
                // Get the input file URL from the query string
                string itemUrl = Request.QueryString["ItemUrl"];
                string inputPath = Site.Url + itemUrl;
                lblInputItem.Text = inputPath;
            }
        }

Convert the document

        protected void btnConvertSharePointFile_Click(object sender, EventArgs e)
        {
            WordAutomationConverterHelper converter = new WordAutomationConverterHelper(SPContext.Current.Site);
            string inputFile = lblInputItem.Text;
            string outputFile = Path.ChangeExtension(lblInputItem.Text, "pdf");

            //Conversion takes place here
            var conversionStatus = converter.ConvertWordDocument(inputFile, outputFile);
            var conversionTime = conversionStatus.CompleteTime.Value.Subtract(conversionStatus.StartTime.Value).Milliseconds.ToString();

            if (conversionStatus.Succeeded)
            {
                lblConvertStatus.Text = string.Format("File converted from <a href='{0}'>{0}</a> to <a href='{1}'>{1}</a>. in {2} milliseconds", inputFile, outputFile, conversionTime);
            }
            else
            {
                lblConvertStatus.Text = string.Format("Something went wrong while converting with message: {0}", conversionStatus.ErrorMessage);
            }
            pnlConversion.Visible = false;
            pnlCompleted.Visible = true;
        }

Download the document

        protected void btnDownloadAsPdf_Click(object sender, EventArgs e)
        {
            WordAutomationConverterHelper converter = new WordAutomationConverterHelper(SPContext.Current.Site);
            string inputFile = lblInputItem.Text;

            byte[] file;
            SPFile document = SPContext.Current.Web.GetFile(lblInputItem.Text);

            var conversionStatus = converter.ConvertWordDocument(document.OpenBinary(), out file);
            if (conversionStatus.Succeeded)
            {
                lblConvertStatus.Text = string.Format("File converted successfully.");
                pnlConversion.Visible = false;
                pnlCompleted.Visible = true;

                Response.Buffer = false; //transmitfile self buffers
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.ChangeExtension(document.Name, "pdf"));   
                Response.BinaryWrite(file);
                Response.End();
            }
            else
            {
                lblConvertStatus.Text = string.Format("Something went wrong while converting with message: {0}", conversionStatus.ErrorMessage);
            }
        }

WordAutomationConverterHelper

    public class WordAutomationConverterHelper
    {
        private SPSite _site;

        public WordAutomationConverterHelper(SPSite site)
        {
            _site = site;
        }

        /// <summary>
        /// Converts the word document.
        /// </summary>
        /// <param name="inputPath">The input path.</param>
        /// <param name="outPutPath">The out put path.</param>
        /// <returns>Conversion Status.</returns>
        public ConversionItemInfo ConvertWordDocument(string inputPath, string outPutPath) 
        {
            SPServiceContext context = SPServiceContext.GetContext(_site);

            //Get default WordService application
            WordServiceApplicationProxy wordProxy = context.GetDefaultProxy(typeof(WordServiceApplicationProxy)) as WordServiceApplicationProxy;

            //Set the settings for the conversion
            ConversionJobSettings jobSettings = new ConversionJobSettings();
            //SaveFormat.Automatic will try to select the format based on the extension of outPuthPath
            jobSettings.OutputFormat = SaveFormat.Automatic;

            SyncConverter converter = new SyncConverter(wordProxy, jobSettings);
            converter.UserToken = _site.RootWeb.CurrentUser.UserToken;

            ConversionItemInfo result = converter.Convert(inputPath, outPutPath);
            return result;
        }


        /// <summary>
        /// Converts the byte array to PDF.
        /// </summary>
        /// <param name="inputFile">The input file byte array.</param>
        /// <param name="outPutFile">The output file as byte array.</param>
        /// <returns>Conversion Status.</returns>
        public ConversionItemInfo ConvertWordDocument(byte[] inputFile, out byte[] outPutFile)
        {
            SPServiceContext context = SPServiceContext.GetContext(_site);

            //Get default WordService application
            WordServiceApplicationProxy wordProxy = context.GetDefaultProxy(typeof(WordServiceApplicationProxy)) as WordServiceApplicationProxy;

            //Set the settings for the conversion
            ConversionJobSettings jobSettings = new ConversionJobSettings();
            jobSettings.OutputFormat = SaveFormat.PDF;

            SyncConverter converter = new SyncConverter(wordProxy, jobSettings);
            converter.UserToken = _site.RootWeb.CurrentUser.UserToken;

            byte[] convertedFile;
            ConversionItemInfo result = converter.Convert(inputFile, out convertedFile);
            outPutFile = convertedFile;

            return result;
        }
    }

Summary

With the possibility for on demand conversions it is now possible to interact immediately with your users and make it possible to create ad-hoc conversions of your word documents.

Restore binary content from unattached database

12. September 2011 07:44 by arnoldbo in SharePoint  //  Tags:   //   Comments

Introduction

When files are accidentally removed from a SharePoint 2010 content database in most circumstances they can be restored through the recycle bin, when files are also removed from the recycle bin it is not possible to restore files on item level basis.

 

When you want to restore those file you have the possibility to connect to a database that is not attached to a SharePoint farm.

Attach backup of database to SQL server

The following MSDN article describes how to attach a database backup file to SQL server: http://msdn.microsoft.com/en-us/library/ms186390.aspx.

Make sure the the account that is used to run the PowerShell operations has read access on the SQL server database

Connect to unattached database

Start a SharePoint 2010 PowerShell console.

Connect the database

$db = Get-SPContentDatabase -DatabaseName "NameOffDataBase" -ConnectAsUnattachedDatabase -DatabaseServer "databaseserver"

 

At this moment the SharePoint API can be used to access content in the content database, execute following command:

 

$db.Sites

 

Example

We want to recover all User Profile images in the MySite Host site collection

 

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue #Create connection to the database $db = Get-SPContentDatabase -DatabaseName "UnattachedDB" -ConnectAsUnattachedDatabase -DatabaseServer "localhost" #Get the list you want to restore information from, in this example we use the first sitecollection in the content database $list = $db.Sites[0].rootweb.lists["User Photos"] #set the view to set the query to retrieve the list items $oView = $list.Views["All Items"] #set the folder you want
Tags van Technorati:
 to retrieve $oFolderChild = $list.RootFolder.SubFolders["Profile Pictures"] #Get the list items $collListItems = $list.GetItemsInFolder($oView, $oFolderChild) Write-Host $collListItems.Count #Iterate over all list items and save the file to your local disk, make sure the file location exists! ForEach ($i in $collListItems ) { Write-Host $i.File.Item.Name $raw = $i.File.OpenBinary() $name = "d:\t\" + $i.File.Item.Name Add-Content $name -Value $raw -Encoding byte }

 

SharePoint MUI Resource files

11. May 2011 06:16 by arnoldbo in SharePoint  //  Tags: ,   //   Comments

In SharePoint 2010 you have the ability to configure alternate languages for a website, this feature enables that navigation and labels are presented in the user selected language without creating variations, when on a farm multiple language pack’s are deployed you can configure Alternate Languages on every site.

Configure Multilangual User Interface

1. goto site settings –> Language Settings

 

image

2. select the languages of choise.

3. press OK to save changes.

 

Change Language on Site

The language of the current site can be changed by slecting the ‘Select Display Language’ in the user menu

image

Using Labels in your solution

When you want to use different languages in your custom solutions it is possible to make use of resource files withing SharePoint.

The SharePoint object model provides Helper methods to get localized strings, the following article on MSDN explains how to use this: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getlocalizedstring.aspx

 

Get current language of user

With SPWeb.Language you get the ‘default’ language of the site in the case of alternate languages it is not sufficient to use this because a user could have set the language to a non ‘default’ language.

 

The current language of a user can be found at: CultureInfo.CurrentUICulture.LCID

 

The following Helper method can be used to retrieve localized strings with respect to the user selected language.

 

public static string GetResourceString(string resourceName, string name)
{
    int languageId = 1033;
    if (SPContext.Current != null && SPContext.Current.Web != null)
    {
        //Set Language to default language of web object! languageId = (int)SPContext.Current.Web.Language; 
   
        //if alternate language is selected by user! if (SPContext.Current.Web.IsMultilingual &&
            SPContext.Current.Web.SupportedUICultures.Where(w => w.LCID == CultureInfo.CurrentUICulture.LCID).
                Any())
        {
            languageId = CultureInfo.CurrentUICulture.LCID;
        }
    }
    return SPUtility.GetLocalizedString(resourceName, name, (uint)languageId);
}

Upgrade localized SharePoint 2007 Publishing site to SharePoint 2010

22. February 2011 06:09 by arnoldbo in SharePoint  //  Tags: , ,   //   Comments

publishing_error

 

Update: March 11 2011

Microsoft KB2484317 for issue with solution

 

http://support.microsoft.com/kb/2484317

 

After a succesfull (according to upgrade log file) upgrade of a SharePoint 2007 localized publishing site, the site is not working, the following error occurs when accessing the portal:

 

Ongeldig SPListItem. Het opgegeven SPListItem is niet compatibel met een publicatiepagina.

[ArgumentException: Ongeldig SPListItem. Het opgegeven SPListItem is niet compatibel met een publicatiepagina.]
Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(SPListItem sourceListItem) +303
Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageStateControl.RaisePostBackEventForPageRouting(String eventArgument, SPRibbonCommandHandler control, RaisePostBackEventDelegate raisePostBackEventDelegate) +110
Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageSaveAndStopEditHandler.RaisePostBackEvent(String eventArgument) +134
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

 

The same message in English:

"Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page."

 

 

Problem

Publishing sites in SharePoint 2007 has a default location for the publishing pages at ‘/Pages/’ in SharePoint 2010 the location has a new name in the Dutch Language pack of ‘/Paginas/’

 

The change has been made in the following resource file: osrvcore.nl-NL.resx

 

<Data Name="List_Pages_UrlName">
  <Value>Paginas</Value>
</Data>

 

Quick Solution

This is not a real solution but this proves that the real solution solves the problem.

 

Step 1: change in the osrvcore.nl-NL.resx the following lines:

 

<Data Name="List_Pages_UrlName">
<Value>Paginas</Value>
</Data>

 

by:

<Data Name="List_Pages_UrlName">
<Value>Pages</Value>
</Data>

 

Warning: it is not supported to change the default resource files.

 

After saving the file and performing an IISreset the site is working with no problems, now we know this we can solve the issue in a more robust way by moving the ‘Pages’ to ‘Paginas’ location.

 

Real Solution

After upgrading localized publishing sites the following steps needs to be performed:

 

Step 1: Move your publishing pages inside the pages library to ‘Paginas’

Create a console application an perform following code on the server, the same can be accomplished by writing a PowerShell script. In this example I know that I only need to change Dutch sites (1043).

 

using (SPSite sitecollection = new SPSite(sitecollectionUrl))
{
    foreach (SPWeb web in sitecollection.AllWebs)
    {
        //Dutch language if (web.Language == 1043)
        {
            foreach (SPList item in web.Lists)
            {
                if (item.RootFolder.Url == "Pages")
                {
                    item.RootFolder.MoveTo(item.RootFolder.Url.Replace("Pages", "Paginas"));
                    item.Update();
                }
            }
        }
    }
}

Step 2: Set the welcomepage location to the new default.aspx

Execute the following code on the server through a console app.

 

using (SPSite sitecollection = new SPSite(sitecollectionUrl))
{
    foreach (SPWeb web in sitecollection.AllWebs)
    {
if (web.Language == 1043)
        {
            if (PublishingWeb.IsPublishingWeb(web))
            {
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                SPFile welcomePage = null;
                welcomePage = web.GetFile("Paginas/default.aspx");

                if (welcomePage != null)
                {
//Set default welcomepage
                    publishingWeb.DefaultPage = welcomePage;
                    publishingWeb.Update();
                }
            }        
        }
    }
}

Step 3: reactivate publishing feature for each site.

In this situation we only had a couple of subsites so we manually disabled and activated the feature for each sub site.

 

publishing_feature

SharePoint 2010 Global List Id’s

29. January 2011 23:55 by arnoldbo in SharePoint  //  Tags:   //   Comments

defaultlists

 

Recently I needed to know the List id of the Theme’s list and wasn’t able to find a list on MSDN so I looked @ the SharePoint root to find out.

 

The SharePoint 2010 Global lists can be found @ “{SharePointRoot}\TEMPLATE\GLOBAL\Lists”, the following list definition’s are available.

 

All these lists are provisioned from the Global ONET.xml (“{SharePointRoot}\TEMPLATE\GLOBAL\XML\ONET.xml”) while creating a new Site collection.

 

 

Internal Name Name Description Id

solutions

Solution Gallery Place to store Solutions 121

mplib   

Master Page Gallery Place to store Master Pages 116

users   

User Information List All users within the site collection 112

webtemp 

Site Template Gallery Gallery for storing custom site designs 111

wplib   

Web Part Gallery Gallery for storing web part definitions 113

listtemp 
 

List Template Gallery Make a template available for use in list creation by adding to this gallery. Default list templates are not shown 114

themes

Theme Gallery Use the theme gallery to store themes. The themes in this gallery can be used by this site or any of its subsites. 123

Provision publishing page with webpart in sandboxed solution

17. August 2010 19:59 by arnoldbo in SharePoint  //  Tags: ,   //   Comments
 

While working with Sandboxed solutions in SharePoint 2010 I faced a problem with attaching a webpart to a publishing page.

The code I used for deploying a page:

   1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   2:   <Module Name="PageInstance"
   3:         Url="Pages"
   4:         Path="PageInstance">
   5:  
   6:     <File Url="test.aspx" Path="default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
   7:       <Property Name="Title" Value="Test Title" />
   8:       <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/customLayout.aspx, My Custom Layout" />
   9:       <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
  10:       <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png" />
  11:       <Property Name="PublishingAssociatedContentType" Value=";#CustomLayout - CustomPages;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00AC43246F7BB54A1389CAF0BEC1C1AEE4;#"/>
  12:       <AllUsersWebPart WebPartOrder="1" WebPartZoneID="Main">
  13:       <![CDATA[
  14:       <webParts>
  15:         <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  16:           <metaData>
  17:             <type name="CustomLayout.SandboxedVisualWebPart1.SandboxedVisualWebPart1, CustomLayout, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9242a569ebe2d353" />
  18:             <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
  19:             <Solution SolutionId="245ba111-9620-424c-9a8f-9eceaa2d33c6" xmlns="http://schemas.microsoft.com/sharepoint/" />
  20:           </metaData>
  21:           <data>
  22:             <properties>
  23:               <property name="Title" type="string">SandboxedVisualWebPart1</property>
  24:               <property name="Description" type="string">My custom sandbox web part</property>
  25:             </properties>
  26:           </data>
  27:         </webPart>
  28:       </webParts>     
  29:       ]]>
  30:       </AllUsersWebPart>
  31:     </File>
  32:   </Module>
  33: </Elements>

The problems with this in a sandboxed solution are:

1. Approval state is set to draft

2. Webpart is not deployed

I realized that there is a good reason that there are problems using this approach because SharePoint will try to load “default.aspx” which is stored in the “SharePoint Root\TEMPLATE\FEATURES\FEATURENAME folder, and Sandbox Solutions doesn’t have access to the SharePoint root.

 
 

On MSDN I found that a module element accepts the “SetupPath” property (http://msdn.microsoft.com/en-us/library/ms460356.aspx) now I rewrote my feature with the “SetupPath” property.

   1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   2:   <Module Name="PageInstance"
   3:         Url="Pages"
   4:         SetupPath="SiteTemplates\SPS"> <!-- Important for sandboxed solution!!! path in file element is using this path for finding location -->
   5:  
   6:     <File Url="test.aspx" Path="default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
   7:       <Property Name="Title" Value="Test Title" />
   8:       <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/customLayout.aspx, My Custom Layout" />
   9:       <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
  10:       <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png" />
  11:       <Property Name="PublishingAssociatedContentType" Value=";#CustomLayout - CustomPages;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00AC43246F7BB54A1389CAF0BEC1C1AEE4;#"/>
  12:       <AllUsersWebPart WebPartOrder="1" WebPartZoneID="Main">
  13:       <![CDATA[
  14:       <webParts>
  15:         <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  16:           <metaData>
  17:             <type name="CustomLayout.SandboxedVisualWebPart1.SandboxedVisualWebPart1, CustomLayout, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9242a569ebe2d353" />
  18:             <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
  19:             <Solution SolutionId="245ba111-9620-424c-9a8f-9eceaa2d33c6" xmlns="http://schemas.microsoft.com/sharepoint/" />
  20:           </metaData>
  21:           <data>
  22:             <properties>
  23:               <property name="Title" type="string">SandboxedVisualWebPart1</property>
  24:               <property name="Description" type="string">My custom sandbox web part</property>
  25:             </properties>
  26:           </data>
  27:         </webPart>
  28:       </webParts>     
  29:       ]]>
  30:       </AllUsersWebPart>
  31:     </File>
  32:   </Module>

 

At this point Path=”default.aspx” is pointing to the physic location: “SharePoint Root\TEMPLATE\SiteTemplates\SPS\default.apx”, so the “default.aspx” file in the module can be removed.

The file “default.aspx” as a template file for a publishing page.

After deploying the feature with this module the state of the page is Approved and the Webpart is available on the page.

Ajax updatepanel SharePoint 2007

22. March 2010 08:37 by arnoldbo in SharePoint  //  Tags: , ,   //   Comments

At a customer place we had issue’s after deploying a page with an Ajax updatepanel, on the development en test environment everything worked fine but on the customer’s acceptance and production environment the first postback in the updatepanel worked but after that the updatepanel didn’t react anymore.

After my collegue and I found the blog post of Mike Ammerlaan we could solve the problem pretty fast.

from Mike Ammerlaan’s Blog:

Using UpdatePanels within SharePoint

UpdatePanels are a very useful addition to ASP.NET AJAX, and represent the simplest way to convert existing, standard ASP.NET controls and parts to take advantage of Ajax techniques.  However, there are some changes within Windows SharePoint Services which may get in the way of working with ASP.NET AJAX.

Windows SharePoint Services JavaScript has a “form onSubmit wrapper” which is used to override the default form action.  This work is put in place to ensure that certain types of URLs, which may contain double byte characters, will fully work across most postback and asynchronous callback scenarios.  However, if your scenarios do not involve double byte character URLs, you may successful disable this workaround and gain the ability to use ASP.NET AJAX UpdatePanels.

For the page’s were we needed the updatepanel we placed the following script:

<script type="text/javascript"> <!-- // Every single time the page loads, including every single AJAX partial postback function pageLoad() {
        _spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper = true }
--> </script> 

Most important of this script is that the fix needs to be applied after every pageload, otherwise only the first postback works fine.

Office 2010 breaks Visual Studio 2008

24. November 2009 12:40 by arnoldbo in Tools  //  Tags: ,   //   Comments

After installing Office 2010 Beta I encountred issues with visual studio, the designer and split view freezes visual studio and caused the application to crash.
on this site I found the solution.

If you get this problem then there is a simple solution, well, one that worked for me. You need to run a repair on the “Microsoft Visual Studio Web Authoring Component” that is part of Office 2007.

Screenshot

 

You can find the setup in the following locations:

Windows 64bit

C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\Office Setup Controller\Setup.exe

Windows 32bit

C:\Program Files\Common Files\microsoft shared\OFFICE12\Office Setup Controller\Setup.exe

 

 

MOSS 2007 Certified developer

24. October 2009 13:38 by arnoldbo in Course  //  Tags: ,   //   Comments

Last friday I passed the  Microsoft Office SharePoint Server 2007 – Application Development (70-542) course with 960 points.

The exam wasn't tough but it's always good to have it on your resume.