我正在开发一个网站,应该是响应,以便人们可以从他们的手机访问它。该网站有一些安全的部分,可以登录使用谷歌,Facebook,…等(OAuth)。

服务器后端是用ASP开发的。Net Web API 2,前端主要是AngularJS加上一些Razor。

对于身份验证部分,在包括Android在内的所有浏览器中,一切都很好,但谷歌身份验证在iPhone上不起作用,它给我这个错误消息

Refused to display 'https://accounts.google.com/o/openid2/auth
?openid.ns=http://specs.openid.ne…tp://axschema.org/namePerson
/last&openid.ax.required=email,name,first,last'
in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

现在就我而言,我没有在我的HTML文件中使用任何iframe。

我搜索了一下,但没有答案让我解决这个问题。


当前回答

下面是我在Iframe中使用并成功显示的代码,我正在c#中使用cshtml制作此代码。

@if (item.DisplayValue2 != null)
{
   <div id="collapse_@item.ID" class="collapse" role="tabpanel" aria-labelledby="heading_@item.ID" data-parent="#accordion" style="">
   <div class="card-body">
      @item.DisplayValue1
   </div>
   <br /> <br />
   @{
       var url = item.DisplayValue2.Replace("watch?v=", "embed/");
     }
    <iframe width="560" height="315" src=@url frameborder="0" allowfullscreen                            style="margin-bottom: 25px; margin-left: 25px;">   
   </iframe></div>

其他回答

下面是我在Iframe中使用并成功显示的代码,我正在c#中使用cshtml制作此代码。

@if (item.DisplayValue2 != null)
{
   <div id="collapse_@item.ID" class="collapse" role="tabpanel" aria-labelledby="heading_@item.ID" data-parent="#accordion" style="">
   <div class="card-body">
      @item.DisplayValue1
   </div>
   <br /> <br />
   @{
       var url = item.DisplayValue2.Replace("watch?v=", "embed/");
     }
    <iframe width="560" height="315" src=@url frameborder="0" allowfullscreen                            style="margin-bottom: 25px; margin-left: 25px;">   
   </iframe></div>

有一个解决方案对我来说很有效,参考父母。在获得将重定向到谷歌身份验证页面的url后,您可以尝试以下代码:

var loc = redirect_location;      
window.parent.location.replace(loc);

我找到了更好的办法,也许能帮到别人 取代“手表吗?V =" by " V /"这是可行的

var url = url.replace("watch?v=", "v/");

使用URL后缀添加以下内容

/override-http-headers-default-settings-x-frame-options

如果你在vimeo中使用iframe,请更改url:

https://vimeo.com/63534746

to:

http://player.vimeo.com/video/63534746

这对我很管用。