none
Can App Parts be used on SharePoint-Hosted pages?

    Question

  • I am trying to create an app part that uses a SharePoint hosted page.  It seems like it should be possible by specifying a path to the page using ~appWebUrl/Pages/MyPage.aspx.  However, nothing I have tried works.  I've also tried just passing an HTML page.  When I use it I get the following error:

    This content cannot be displayed in a frame

    To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.

    Any ideas?



    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth


    Wednesday, August 01, 2012 2:25 AM

Answers

  • The page must be allowed to run in the frame.

    You can do this by adding the following to the top of the page ->

    <!-- The following tells SharePoint to allow this page to be hosted in an IFrame -->
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <WebPartPages:AllowFraming runat="server" />

    Wednesday, August 01, 2012 5:24 PM

All replies

  • The page must be allowed to run in the frame.

    You can do this by adding the following to the top of the page ->

    <!-- The following tells SharePoint to allow this page to be hosted in an IFrame -->
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <WebPartPages:AllowFraming runat="server" />

    Wednesday, August 01, 2012 5:24 PM
  • Thank you!  I figured there was something like that I had to add.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Wednesday, August 01, 2012 5:25 PM
  • If you don't mind, I would like to open this discussion again. 

    In this example a HTML page is used and not an aspx page. (http://msdn.microsoft.com/en-us/library/fp179921%28v=office.15%29.aspx?lc=1033)

    There is no mention of using allowframing in the above article. Also using the information here and in Corey's article here: http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/08/01/how-to-build-a-sharepoint-hosted-client-web-part-in-sharepoint-2013.aspx I am still getting the following error: The page must be allowed to run in the frame.

    Is there an issue using the O365 Dev Preview with this?

    On a side note, I am also getting this warning in VS2012: 

    Warning 3 Element 'AllowFraming' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing. C:\Users\Synt12\Documents\Visual Studio 2012\Projects\sp2013PhotoGallerySpotlight\sp2013PhotoGallerySpotlight\Pages\Page1.aspx 12 19 sp2013PhotoGallerySpotlight

    Monday, October 01, 2012 2:03 PM
  • Just to clarify.

    You are probably using a SharePoint-hosted page as the content for the app part. The MSDN article mentioned above does not use a SharePoint-hosted page. It uses a simple HTML page and as such can be used as the content of the app part without adding any allowframing elements. If you use a SharePoint-hosted aspx page you probably (or most likely) have to add the allowframing element. 

    If you're following Corey's blog post make sure you add:

    <WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />
    to the SharePoint-hosted page that works as the content of the app part. Not to the page that hosts the app part.

    Ricalo

    Monday, October 01, 2012 5:21 PM
  • The MSDN article is probably autohosted. And following their steps, I added an HTML page and still get the error: The page must be allowed to run in the frame.

    The article from Corey is SharePoint hosted and if I add either HTML or aspx page, I will get the following error:The page must be allowed to run in the frame.

    Your comment is not actually true, you have to add in the WebPartPages:AllowFraming but also include the register statement as well. Both of these items have been added to the newly created page not the host page. 


     

    Monday, October 01, 2012 6:14 PM
  • I decided to create another SharePoint hosted application from scratch....and this mysteriously works now. I'm at a loss of words. My troubleshooting steps involved creating a new project to follow the steps from the MSDN link and was able to duplicate the issue. But as of right now, the steps in Corey's blog post are solid. 

    Thanks SharePoint!

    Monday, October 01, 2012 8:17 PM
  • Awesome.  Were you able to get an HTML page to work? or just an .aspx page?

    Corey


    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Monday, October 01, 2012 8:25 PM
  • What I had working is the .aspx page. What I just attempted to do was add another Client Web Part and then add a HTML page to the project. When I deployed, my webpart that used to work (the .aspx page) started giving me same error. So I deleted the new stuff and retracted the solution manually. Re-deployed and now it works again. (the .aspx page). Thinking that scenario is strange, I tried it again and now my webpart is giving the usual error. So right now, nothing works. 

    If you were were able to follow that...give yourself some credit. 

    At this point, I think it is fair to say that something buggy is going on. I can get to my new pages by entering the webpart URL manually. So I'm going to continue working that way with the anticipation that this will get ironed out later. Someone else can beta test this. I'm not bitter, kudos to the product team for getting this far and I understand that this is all in beta. 

    Monday, October 01, 2012 9:22 PM
  • I assumed your page already had the Register statement since VS creates that for you in newly created pages in SharePoint-hosted apps.

    The MSDN sample does not need the Register or AllowFraming since it is not running on SharePoint and it is not even an aspx page.

    Check the Extending SharePoint UI in apps section in the following article for more details:

    http://msdn.microsoft.com/en-us/library/jj220046(v=office.15).aspx#UXGuide_Extending

    Monday, October 01, 2012 10:37 PM
  • Ricardo, two people on this thread cannot get HTML pages to render in an app part properly. Please un-mark your original response from being a proposed answer. 
    Tuesday, October 02, 2012 2:22 PM
  • Corey, I'm starting to pick up that the error will go away if I manually navigate to my app first...then go to the page on the top level site and hit refresh. 
    Tuesday, October 02, 2012 4:25 PM
  • Corey, have you fiddled with your HTML Field Security settings at all? Keeping mine at default, I suspect that might be the culprit from keeping HTML pages out.
    Monday, October 08, 2012 7:09 PM
  • Just to clarify.

    You are probably using a SharePoint-hosted page as the content for the app part. The MSDN article mentioned above does not use a SharePoint-hosted page. It uses a simple HTML page and as such can be used as the content of the app part without adding any allowframing elements. If you use a SharePoint-hosted aspx page you probably (or most likely) have to add the allowframing element. 

    If you're following Corey's blog post make sure you add:

    <WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />
    to the SharePoint-hosted page that works as the content of the app part. Not to the page that hosts the app part.

    Ricalo

    It appears that this happens still even if this is added to the SharePoint-hosted page of the app part, but I realized that this is not happening all of the time. The issue is not happening with Chrome, Firefox, or even Internet Explorer 8. This is happening when trying to view a client app part on a page with Internet Explorer 10. It still occurs even after changing the browser mode to a previous browser or adding the app's URL to Trusted Sites.

    I believe it is an issue specific to Internet Explorer 10 and maybe whatever the AllowFraming server control winds up rendering out to support the content to be display within a frame.

    Can those that are having an issue with adding a client app part to a page in the host site verify if it is an issue in other browsers?



    • Edited by dream in code Friday, October 26, 2012 4:29 PM Added comment about browser modes
    Friday, October 26, 2012 4:25 PM
  • Given the descriptions of the errors here, it sounds like many of you might be running into a known issue in the beta with the way SharePoint's authentication mechanisms work with cross-Security Zone iframes in IE 9/10.  To get unblocked for now, you can either use a different browser or try navigating to the app web directly before trying to render the part itself.

    Elisabeth Olson SharePoint PM - MSFT

    Friday, October 26, 2012 4:44 PM
  • Thanks Elisabeth,

    Since I'm using the Office 365 Preview, I was able to work around the issue for now by also adding *.microsoftonline.com to Trusted Sites, in addition to the host web and app web URLs.

    While this should be fine for now, do you know if this may be something that should be resolved in a product or service update, or will we need to account for this in our custom apps?

    I would assume since the app in this case is SharePoint-hosted, that the issue is with the authentication mechanisms and the microsoftonline.com domain, and that a custom proxy page to function between the host web on site.sharepoint.com and the app web on site-appid.sharepoint.com would still not work.

    Friday, October 26, 2012 6:14 PM
  • This is actually not really something your app can or should work around.  The workaround you mentions should work to unblock your development, and the issue is fixed in the RTM build.

    Elisabeth Olson SharePoint PM - MSFT

    • Proposed as answer by dream in code Friday, October 26, 2012 6:33 PM
    Friday, October 26, 2012 6:23 PM
  • Hello,

    I want to use showModalDialog in a Sharepoint 2013 sharepoint-hosted app. (not an app part)
    but getting an "error" page:

    "This content cannot be displayed in a frame
    To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame."

    but there is an link under the error:

    "What you can try:
    Open this content in a new window"

    When I click on the link, then the dialog will be opened in an other page (fullscreen). Thats not what i want.

    I have tried:

    <WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />

    And add the sites to trusted.

    Regards,

    Harm

    Wednesday, January 02, 2013 3:10 PM
  • The initial problem outlined in this thread is closed and has been fixed. I can understand that it might look related to your issue but I suggest opening this up in a new thread might be more helpful in getting a response. 
    Wednesday, January 02, 2013 8:01 PM
  • HI.

    I tried to this but this is not work. It is give to Error..

    Friday, February 01, 2013 5:37 AM
  • Hi..

    If you add this Element

    <WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />


    Then give this Error as i mention bellow

    "An error occurred during the processing of /Appname/Pages/Pagename.aspx. Only Content controls are allowed directly in a content page that contains Content controls."


    Friday, February 01, 2013 5:39 AM
  • Hi,

    DO not try to this in your page i have tried to this but i got the Error like this...

    "An error occurred during the processing of /Appname/Pages/Pagename.aspx. Only Content controls are allowed directly in a content page that contains Content controls."

    Friday, February 01, 2013 5:42 AM
  • Sorry to jump in a year later, but I can't find the answer.

    What file do you add

    <!-- The following tells SharePoint to allow this page to be hosted in an IFrame -->
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <WebPartPages:AllowFraming runat="server" />

    to? and where is the file located?

    I tried web.config and that just messed everything up

    Wednesday, October 16, 2013 12:50 PM