最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - How do I correctly embed an <iframe> in Blazor? (child App) - Stack Overflow

programmeradmin5浏览0评论

I have created a sample blazor webAssembly applcation and wanted to load that in the container app created in blazor standalone webassembly.

I am using iframe to load the child app however it shows

chromewebdata/:1 Refused to display 'https://localhost:7239/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

my code

@page "/"
<h3>Main Container Application</h3>

<iframe width="560" height="315" src="https://localhost:7239/" frameborder="0"></iframe>

I have created a sample blazor webAssembly applcation and wanted to load that in the container app created in blazor standalone webassembly.

I am using iframe to load the child app however it shows

chromewebdata/:1 Refused to display 'https://localhost:7239/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

my code

@page "/"
<h3>Main Container Application</h3>

<iframe width="560" height="315" src="https://localhost:7239/" frameborder="0"></iframe>
Share Improve this question asked Mar 18 at 7:03 Talal HabibTalal Habib 212 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

In the program.cs of "server project" in frame website WebApp (https://localhost:7239/), add following code to remove "X-Frame-Options" header will solve this issue.

app.Use(async (context, next) =>
{
    context.Response.Headers.Remove("X-Frame-Options");
    await next();
});

app.MapRazorComponents<App>()
...
发布评论

评论列表(0)

  1. 暂无评论