aspx页面中的iframe

时间:2015-10-29 17:40:14

标签: asp.net firefox iframe

我有一个在aspx页面的iframe内运行的MVC应用程序。原因是我需要能够使用网站母版页。我一直从firefox "The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it"收到以下错误。这是因为需要为iframe指定doctype吗?我的cshtml页面的顶部看起来像这样

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">

我的aspx页面看起来像这样

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/CATSMaster.master" AutoEventWireup="true" CodeBehind="CATS.aspx.cs" Inherits="Cats.CATS.Cats.MoreCats" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CatsContentPlaceHolder" runat="server">
    <iframe style="height:1080px;width:975px;" src='<%= Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
(Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port) + "/Mvc/Cats/MoreCats" %>'></iframe>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
</asp:Content>

如何更正此错误并明确声明iframe的doctype?

1 个答案:

答案 0 :(得分:1)

将以下声明添加为iFrame中显示的页面<head>部分的第一行

<meta http-equiv="Content-type" content="text/html;charset=utf-8">