In my sharepoint site (Sharepoint Server Enterprise 2010), in IIS(7.5), I have a web-application that runs with Sharepoint as the parent site.


So, I want to use a jQuery library called gg-orgchart within my web-application. Now, the code I have works fine in a site on the same IIS that isn't a sub-web of sharepoint. But for some reason sharepoint won't let me draw upon the json information.

Do I need to use a web-service (like they talk about here) to get this library to work? I've never worked with web-services (or created them) yet, so I'm not sure what I'm doing.

The error I get in Firebug is:

DragOn fly...
drag-on.js (line 208)
GET http://saintvirtus/matrix/demo.json?_=1407897823316

500 Internal Server Error
jquery.js (line 8526)
"NetworkError: 500 Internal Server Error - http://saintvirtus/matrix/demo.json?_=1407897823316"

The 500 Internal Server Error serves this comment into the browsers' html instead of loading the json file.

[HttpException]: The page must have a &lt;%@ webservice class=&quot;MyNamespace.MyClass&quot; ... %&gt; directive.
   at System.Web.UI.SimpleWebHandlerParser.ParseString(String text)
   at System.Web.UI.SimpleWebHandlerParser.ParseReader()
[HttpParseException]: The page must have a &lt;%@ webservice class=&quot;MyNamespace.MyClass&quot; ... %&gt; directive.
   at System.Web.UI.SimpleWebHandlerParser.ParseReader()
   at System.Web.UI.SimpleWebHandlerParser.Parse(ICollection referencedAssemblies)
   at System.Web.Compilation.SimpleHandlerBuildProvider.get_CodeCompilerType()
   at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
   at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
   at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context)
   at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
   at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

But if I open the html file as a file:// in the webbrowser, it works fine. So I conclude it is an issue with sharepoint interfering.

So, do I need to use a webservice, or is there an easy way out? Or can I fix this without manually adding any .net code?


  • This is not cross-domain. Sharepoint is like: https://my.portal.com, and the web-application is at https://my.portal.com/subweb and is running in IIS as a web-application under sharepoint's own site.
  • The sub-web does not use Sharepoint for its Master Pages.
  • I confirm that jQuery is working and my javascripts are loading.
  • I confirm that the MIME type for json is in IIS's root settings and is application/json
  • Now, I tried the solution on this page, but it served me an error on the page request.
  • Also, I see that the gg_orgchart.js library uses $.getJSON.

As the code sample was requested, here is the pertinent snippet from the library:

// get the JSON (if its name is passed thru); if not passed, do nothing, because the "data" is already in the data heap
if (merged.oc_json_file !== null) {
    $.getJSON(merged.oc_json_file, function (loaded_data) {
        if (typeof loaded_data != "object")
            loaded_data = { "id": 1, "root": { "id": 1, "title": "data: bad specification" } };
        else if (parseInt(loaded_data.id) <= 0)
            loaded_data.id = 1;
    } ); 


I tried a second test. I added a virtual directory to the root of the portal site. This is not a web-app. And I put the contents of the ogg_orgchart library into it directly. The pages load, but the json does not. Thus, it isn't a matter of using a web-app under sharepoint - it is a matter of Sharepoint restricting the fetching of json.


Still haven't solved this. I had a lengthly discussion with the authour of SPServices.js (who kindly posted below) who says there should be no issue with opening .json files. But I did get the library to work fine using .txt files. I still haven't figured out the .json issue.

  • It's not clear how this isn't cross-domain since you have two completely different sites. If this works on your one site, ever thought of using an iframe?
    – iOnline247
    Aug 13, 2014 at 12:43
  • 1
    I explained further about not being cross-domain. They are running in the same virtual site.
    – bgmCoder
    Aug 13, 2014 at 13:22
  • It's very hard to tell with the snippet you've posted. I'd just try to get the $.getJSON() call running first. Are you sure that merged.oc_json_file contains a valid URL to the file? The file also must be valid JSON for $.getJSON() to work. If there 's a syntax error, it will fail. Finally, try stepping through your code and inspecting the variables to see what you get back. You can also use Firebug or Fiddler to look at the Net traffic. Aug 13, 2014 at 13:50
  • When I run the html demo file by double-clicking on the file itself to load it through the file system (instead of running it in the webserver) it works fine. If the json were invalid it would not work. I already posted my net traffic from firebug in my post. I'll look at it again and add some more details.
    – bgmCoder
    Aug 13, 2014 at 13:53
  • Ah - here are more details.
    – bgmCoder
    Aug 13, 2014 at 13:57

4 Answers 4


per your repeat of the question on my SPServices site, you don't need SPServices for this. Fetching a JSON file from inside SharePoint should be a simple $.get() or $.getJSON call. Since you didn't post your code, I'm not sure what the issue is, but you should be able to fetch any valid JSON file which is accessible via a URL.



SharePoint does not allow to get directly a .json file without passing by a Web Service. It's considered as a non-sense for Microsoft, so they simply blocked .json file, if not provided by a web service.

For some cases, you can rename your .json file to .jso to trick the SharePoint security policy, or go to Web.config to disable the security check. At this line :

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

In some other cases (like mine), I'm using the http.get method from AngularJS and it won't be able to find the .jso file, and in my app, I can't change the policy. So I simply used an XML file, and parsed it like we can do with a Json. It's not object oriented, but once parsed and stored into an array, can be used like your json datas. Or you can as well use the iframe trick that iOnline247 written.


Since you own both apps, SP and your custom .Net app, you could load your .Net app in SP via an iframe. The URL that is loaded can then take advantage of using postMessage and push the JSON to SP. I've done this before and works well.

It'll save you the hassle of creating another service to do this.


http://blog.teamtreehouse.com/cross-domain-messaging-with-postmessage http://dev.opera.com/articles/window-postmessage-messagechannel/

  • Well, I've tried a Page-Viewer web-part to no avail - the page loads, but the json doesn't. I've also tried adding an iframe using the html editor in a regular sharepoint page, but Sharepoint removes the html code. So, I added the iframe directly to the page.aspx using Sharepoint Designer in code-editing mode. It still doesn't display the json. Again, this also isn't cross-domain.
    – bgmCoder
    Aug 16, 2014 at 14:36

In the end I solved the problem by renaming the file on the server from myfile.json to myfile.txt. After that I was able to load it.

I'm not sure why this made any difference, though, because I have .json registered as a MIME type in IIS both for sharepoint and for the sub-web.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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