Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To enable inclusion of http links within an iframe on a .NET Core 6 Blazor Hybrid application, you can add a Content Security Policy (CSP) that allows the loading of external resources.

  1. Add the following code to the Startup.cs file to enable CSP:
app.Use(async (context, next) =>
{
    context.Response.Headers["Content-Security-Policy"] = "default-src 'self' https:";
    await next();
});
  1. In the Blazor component where you want to include the iframe, add the following code:
<iframe src="http://example.com"></iframe>

This should allow the inclusion of http links within iframes in your Blazor Hybrid application. Note that this approach can potentially expose your application to security risks, so use it with caution and only allow trusted domains.