5

In a standard team site, I have a document library that host a static website with html files as well json files loaded asynchronously with javascript.

This was working well in SharePoint 2007. unfortunately, since we migrated to SharePoint 2010, a http GET request on a JSON file fails with:

An error occured while processing resource /foo/bar.json. The page must have a <%@ webservice class="MyNamespace.MyClass" ... %> directive.

This just doesn't make sense. I want the json file to be served as a plain-text resource.

How can I fix this error?

  • I translated the error message from French to English myself. Please edit the question if you know how the genuine message. – rds Feb 11 '13 at 10:32
  • I am facing the same problem, which web.config file I should modify? I just want to modify only for one site not for the whole server. Thanks in advance. Raghu – Raghu Jul 4 '13 at 6:56
3

It's not a good idea to disable the handler. In SharePoint 2013, some services like Managed Metada or Excel Services are relying on it and won't work anymore without it.

For example, when you open an Excel file in SharePoint using Excel services, the page calls some .json files when loading : [myserver]/_vti_bin/DynamicGridContent.json/GetRangeContent

Or when you want to select a value in a managed metadata field : [myserver]/_vti_bin/TaxonomyInternalService.json/ValidateTerms

You can find the complete list of JSON used by SharePoint in the ISAPI folder : enter image description here

So, instead of disabling the handler, you can filter the path to apply the handler only on files from the /_vti_bin/ folder :

<add name="JSONHandlerFactory" allowPathInfo="true" path="/_vti_bin/*.json" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" preCondition="integratedMode" />

And so you will be able to store and call your own .json in a document library without impacting other features.

  • Note that I didn't recommend to disable the handler. Using a path filter sounds like a good workaround. – rds Feb 20 '16 at 21:03
  • I can upload json files but can't edit when mapped to network drive. – jpfreire Jun 15 '18 at 19:43
1

The default web.config contains in <system.webServer><handlers> this handler:

<add name="JSONHandlerFactory" path="*.json" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" preCondition="integratedMode" />

As such, SharePoint thinks that URLs ending with .json are backed up by a web service.

I don't know whether native fonctionnalities rely on such services, hence I don't think it's a good idea to disable this handler. Apparently, Microsoft didn't think that the storage of JSON files in a document library is a valid use case.

  • Already added this string in web.config still getting this error. – Kaushal Khamar Feb 3 '16 at 12:14
0

This is not the best practice but it worked for me: rename to .TXT and it will work as good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.