SharePoint Blog

Developing Apps for SharePoint 2013

I’m basically using my blog right now as a public scrapbook. I simply log every issue I run into when I developing my first SharePoint 2013 hosted App.

Issue 1. – JavaScript Error(s) when deploying/testing my first App Part (15th March 2013)

An App Part is basically a very simple yet effective solution to add functionality to the host web (the web hosting the app): It simply is an IFrame that displays a page hosted elsewhere. In my scenario of a SharePoint hosted app this page is hosted in a subsite i.e. in the app web just below the host web. However, IE9 seems to have difficulties handling script loading in an IFrame that is added after the IFrame’s hosting page already completed loading. If I create a simple SharePoint hosted App Project in Visual Studio 2012 and add a Client Web Part (Host Web), press F5 and navigate back to the host web to add the App Part (=Client Web Part) to a (newly created wiki page) in the host web, the solution breaks on the following error:

Error: 'Object' is undefined

It points to jQuery’s statement

// Save a reference to some core methods
toString = Object.prototype.toString,

Later I found that also other global JavaScript objects, i.e. Function and Type were not registered. This error can be “surpressed” in two ways:

1. Make sure that the page isn’t loaded in IE9 Compat View. Also ensure that IE by default doesn’t want to display all intranet sites in Compatibility View by clearing the tick in the box here Tools > Compatibility View Settings > Display Intranet Sites in Compatibility View.

2. However, it’s not always that easy to control IE9′s Compatibility View Settings and hence I added the following JavaScript as the first statement in the document’s head:

<script type="text/javascript">
if(typeof(Object)==="undefined"){
window.location.reload();
}
</script>

More info here: http://stackoverflow.com/questions/8389261/ie9-throws-exceptions-when-loading-scripts-in-iframe-why

Issue 2. – Each time when debugging from VS2012 (F5′ing) I need to enter my credentials

A quick look with Fiddler showed that credentials aren’t sent (ah well, who would have guessed with the “Enter credentials box” popping up). Since the isolated App domain (*.app.futurama.local in my case) was properly configured in DNS and host file I could solve the problem by adding *.app.futurama.local to IE’s intranet sites.

Copyright ©2012. All Rights Reserved.