Thursday, September 29, 2016

How to Allow cross domain access in SharePoint 2013 Modal Dialog Box

Consider one scenario: You have two web applications. There is a page in one web application (let’s say Source web application). In this page there is button. On click the button you need to open a Modal Dialogue Box. In this Modal Dialogue box, you called a page located in another web application. If you try this, you will get bellow error:

"Refused to display 'http://contoso/pages/home.aspx' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'."

To get rid of this problem, add the below line in the master page of the source web application:
<!--SPM:<WebPartPages:AllowFraming runat="server" />-->

It should look like below screen:


Next you need to download the following wsp from CodePlex:

This is a Farm Level Feature. Download and install it in the central Admin and enable the feature for both the web application. Now you can open the page without any problem.


Cheers!!