Recently, we encountered an interesting and quite unexpected issue while working on a publishing site based on SharePoint 2013. Let me share some details on that particular scenario and a simple workaround in case you come to struggle with the same problem.
A client of ours has a large number of pictures that they use when authoring content for a publishing site. They store the images in the Site Collection Images library. To make it easier to classify the images and simplify the work of content authors, they added a Managed Metadata field named Category to the library. This works pretty well since a new feature in SharePoint 2013 now allows to conveniently sort and filter by taxonomy fields in the list view:
The problem surfaces when content authors want to use the images in the pages they create. In SharePoint 2013 when the user selects to insert a picture from SharePoint into a page, s/he is presented with the Asset Picker dialog showing the default view of the Site Collection Images library:
However, an attempt to filter by the Category field fails, resulting in the following unhandled exception raised in the Asset Picker dialog source code:
[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.] System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +166 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +760 System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +79 System.Web.UI.HiddenFieldPageStatePersister.Load() +329 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +272 Microsoft.SharePoint.WebControls.DeltaPage.LoadPageStateFromPersistenceMedium() +41 System.Web.UI.Page.LoadAllState() +51 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5790 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +720 System.Web.UI.Page.ProcessRequest() +119 System.Web.UI.Page.ProcessRequest(HttpContext context) +142 ASP._layouts_15_assetportalbrowser_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\23e59bfb\5b5d2c5e\App_Web_assetportalbrowser.aspx.9c9699a8.utdd9vlr.0.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +183
This is yet another reminder to never bet money that something is going to work in SharePoint unless one tried it first. On at least two environments!
Since the issue is coming from the ASP.NET page processing pipeline and it is quite generic, there are hundreds of hits if we look it up on the net. But there is none that applies to SharePoint 2013 in this particular scenario. We are in need of a workaround.
Fortunately, there is a workaround and it is based on the Metadata Navigation and Filtering feature which has been around since SharePoint 2010.
In order to configure that first we need to open our site’s features page and activate the Metadata Navigation and Filtering feature at the site level:
Then, from the Library Settings page of the Site Collection Images library, we click on the Metadata navigation settings link:
In the Metadata Navigation Settings page we configure a navigation hierarchy based on the Category taxonomy field and save our changes:
Now, back in our Site Collection Images list view we get a tree-like navigation that allows us to filter by the values of the Category field:
And finally, we are also able to filter by the Managed Metadata field values in the Asset Picker dialog:
Another happy client or as they say “All’s well that ends well”.
Thanks for your post! Unfortunately, your workaround does not work if Managed Metadata Column contains not only terms at 1st level, but also sub-terms. In this case, asset picker error remains.
Thanks for pointing out this limitation, we didn’t really need sub-verbs in our scenario. Unfortunately, I’m not aware if Microsoft have fixed / are planning a fix for this issue in one of the update packs.