Is there any way of showing Microsoft Dynamics CRM 2016 pages in an HTML iFrame? I was trying to add the X-frame options in the installation web config but it did not help.
2 Answers
I'm pretty sure this is a security feature of CRM. Having CRM iframed into another site would open up for XFS.
It looks like X-Frame-Options does not work to authorize multiple domains and the approach to take is to use the Content-Security-Policy header instead. This thread discusses the same type of issue X-Frame-Options Allow-From multiple domains
The links below have information on how to use the Content-Security-Policy header:
https://content-security-policy.com/
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
This web.config snippit below looks like it works to me (I tried this on a CRM 2013 Box).
<httpProtocol>
<customHeaders>
<!-- seems to work correctly and override X-Frame-Options -->
<add name="Access-Control-Allow-Origin" value="http://localhost" />
<add name="Content-Security-Policy" value="frame-ancestors 'self' localhost crmserver; script-src 'unsafe-eval' 'unsafe-inline' 'self' localhost crmserver;" />
</customHeaders>
</httpProtocol>
Where localhost is the iFrame hosting the CRM window and crmserver is the crmserver dns name
edit: It look like Content-Security-Policy is only supported Chrome and Firefox at the moment. IE does not support the Access-Control-Allow-Origin