在其他网站的iframe中显示MVC页面

时间:2019-03-09 07:36:00

标签: c# html asp.net asp.net-mvc iis

我在.net MVC中创建了一个新应用程序,并且我试图在其中的iframe中显示“ http://localhost:62908/Home/Index”  'http://127.0.0.1:5500/index.html'所以我出错了

  

拒绝在框架中显示“ http://localhost:62908/Home/Index”   因为它将“ X-Frame-Options”设置为“ sameorigin”。

然后我尝试添加

<add name="X-Frame-Options" value="*" />

然后我得到错误

  

拒绝在框架中显示“ http://localhost:62908/Home/Index”   因为它设置了多个带有冲突的“ X-Frame-Options”标题   值(“ SAMEORIGIN,AllowAll”)。退回到“拒绝”状态。

最后我尝试了这个

  protected override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        System.Web.HttpContext.Current.Response.Headers.Remove("X-Frame-Options");
        System.Web.HttpContext.Current.Response.Headers.Add("X-Frame-Options","ALLOWALL");
        base.OnResultExecuted(filterContext);
    }

它奏效了。但是还有其他更好的方法吗?

  1. 为什么Web配置中的值没有覆盖现存的值 2.其他更好的方法

0 个答案:

没有答案
相关问题