Fixed: Framing '…' Violates the Following Content Security Policy Directive: "frame-ancestors …" in a Teams Dialog
A Teams dialog that should have shown my agent's web page showed a grey area with a sad-page icon, and the browser's console said Framing '…' violates the following Content Security Policy directive: "frame-ancestors https://teams.microsoft.com https://*.teams.microsoft.com". The page allowed Teams' old addresses, but Teams on the web now runs at teams.cloud.microsoft.
What I Was Doing
An agent built with the Microsoft 365 Agents SDK opens a Teams dialog that shows a page it serves itself, parking.html, through a dev tunnel. To stop other sites from showing its pages inside their own, the agent sends a Content-Security-Policy header with a frame-ancestors directive, set in Program.cs. I listed the Teams addresses I knew:
// Only Teams may show these pages inside its own page.
app.Use(async (context, next) =>
{
context.Response.Headers.ContentSecurityPolicy =
"frame-ancestors https://teams.microsoft.com https://*.teams.microsoft.com";
await next(context);
});
Then I opened the dialog in Teams on the web.
What I Expected
A dialog titled Visitor parking, with two lines about where visitors park.
What I Got
A grey page with a sad-page icon:

Chrome's error page in the frame showed only that icon, and its text read cdzngt35-3980.inc1.devtunnels.ms refused to connect. The browser's console, which F12 opens in Chrome and Edge, said why:
Framing 'https://cdzngt35-3980.inc1.devtunnels.ms/' violates the following Content Security Policy directive: "frame-ancestors https://teams.microsoft.com https://*.teams.microsoft.com". The request has been blocked.
What I Checked
Whether the agent served the page. It did. The agent's request log showed the dialog request, then the page sent with 200:
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://localhost:3980/api/messages - 200 - application/json;+charset=utf-8 27.1957ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:3980/parking.html - - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://localhost:3980/parking.html - 200 697 text/html 3.4391ms
So the browser received the page, with its header, and then refused to show it.
What the message means. frame-ancestors lists the pages allowed to show this page in a frame. The message quotes my own list back, so the page that framed it wasn't on the list.
Where Teams on the web runs. The browser's address bar showed https://teams.cloud.microsoft/. That isn't teams.microsoft.com, and it isn't under teams.microsoft.com either.
What Microsoft's documentation says. The requirements for tabs list the frame-ancestors values for each Microsoft 365 host. The first row is new:
| Microsoft 365 app host | frame-ancestor permission |
|---|---|
| All hosts (New) | *.cloud.microsoft |
| Teams | teams.microsoft.com, *.teams.microsoft.com |
The same page warns: Microsoft's cloud services, including web versions of Teams, Outlook, and Microsoft 365 domains, are migrating to the *.cloud.microsoft domain. It asks apps to update the frame-ancestors directive to include the *.cloud.microsoft domain, and to retain the existing frame-ancestors values in your CSP headers for backward compatibility.
Why It Happens
Teams on the web moved to teams.cloud.microsoft, and my frame-ancestors list only had Teams' older addresses. The browser checks the list against the pages that frame the dialog's page. teams.cloud.microsoft didn't match, so the browser blocked the frame and showed its own error page instead.
The Fix
Add https://*.cloud.microsoft to the list, and keep the values that were already there:
// Only Teams may show these pages inside its own page.
app.Use(async (context, next) =>
{
context.Response.Headers.ContentSecurityPolicy =
"frame-ancestors https://teams.microsoft.com https://*.teams.microsoft.com https://*.cloud.microsoft";
await next(context);
});
https://*.cloud.microsoftcoversteams.cloud.microsoftand the other Microsoft 365 apps that have moved to that domain.- The two older values stay, as Microsoft's page asks, for backward compatibility while the move goes on.
Stop the agent with Ctrl+C and start it again with dotnet run, so it sends the new header. How to Add a Content-Security-Policy Header in ASP.NET Core (C#) explains this middleware and how to check the header with curl -I.
If your app also runs in Outlook or the Microsoft 365 app, the same table on Microsoft's page lists their values too.
After the Fix
The same dialog showed the page:

The console had no frame-ancestors message this time.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
A frame-ancestors list with only teams.microsoft.com and *.teams.microsoft.com | Teams on the web, at teams.cloud.microsoft, is blocked | Add https://*.cloud.microsoft |
Replacing the old values with *.cloud.microsoft | Microsoft asks apps to keep them during the move | Keep them and add the new one |
| Editing the header without restarting the agent | The old header is still sent | Restart the agent |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| A grey dialog with a sad-page icon, and violates the following Content Security Policy directive: "frame-ancestors …" in the console | The page's frame-ancestors doesn't include the address Teams runs on | Add https://*.cloud.microsoft |
| The page opens in its own browser tab but not in Teams | frame-ancestors applies only when another page shows yours in a frame | Check the console of the Teams tab, not the page's own tab |
| Still blocked after the change | The agent is still running the old code | Stop it and run dotnet run again |
FAQ
Do I need a frame-ancestors directive at all?
Without one, any site can show your page inside its own. With one, only the hosts you list can. Microsoft's requirements for tabs ask you to set it so that Teams and the other Microsoft 365 hosts are allowed.
Why does the console show the tunnel's address and not my page's?
Chrome names the framed page's origin, its scheme, host and port, rather than its full address, so the message shows https://cdzngt35-3980.inc1.devtunnels.ms/ for parking.html. The directive quoted after it is the one your page sent.
Conclusion
Framing '…' violates the following Content Security Policy directive: "frame-ancestors …" in a Teams dialog means your page's frame-ancestors list doesn't include the address Teams runs on. Teams on the web is at teams.cloud.microsoft, so add https://*.cloud.microsoft and keep https://teams.microsoft.com https://*.teams.microsoft.com, as Microsoft's requirements for tabs ask.
Additional Resources
- Requirements for building tabs, on Microsoft Learn.
- Content-Security-Policy: frame-ancestors directive, on MDN.
