加了格式没转换竟然,应该是这样:<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Index.master.cs" Inherits="Web.Template.Index" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>
        <%=Application["PageTitle"] %></title>
    <meta name="keywords" content="<%=Application["PageKeywords"]%>" />
    <meta name="description" content="<%=Application["Pagede"] %>" />
    <link href="../CSS/Index/Index.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
 </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    <%= %> 这种需要放在body 中,放在head肯定会出错的
      

  2.   

    Refer here:
    http://www.cnblogs.com/insus/archive/2011/03/21/1990274.html
    http://www.cnblogs.com/insus/archive/2011/04/21/2023258.html
    http://zzk.cnblogs.com/s?w=blog%3Ainsus+meta&t=
      

  3.   


     <title>
            <%=Application["PageTitle"] %></title>
        <meta name="keywords" content="<%=Application["PageKeywords"]%>" />
        <meta name="description" content="<%=Application["Pagede"] %>" />这些信息不能放到Body中吧
      

  4.   


     <title>
            <%=Application["PageTitle"] %></title>
        <meta name="keywords" content="<%=Application["PageKeywords"]%>" />
        <meta name="description" content="<%=Application["Pagede"] %>" />这些信息不能放到Body中吧http://zjc369.blog.sohu.com/19374962.html
    试试写后台呢
      

  5.   


    /// 
    /// 添加Meta标签 
    /// 
    /// 页面 
    /// Meta名字 
    /// Meta内容 
    public void AddMeta(System.Web.UI.Page page, string name, string content) 

    HtmlMeta meta = new HtmlMeta(); 
    meta.Name = name; 
    meta.Content = content; 
    page.Header.Controls.Add(meta); 
      

  6.   


    要用全局变量Application。
      

  7.   

    把<%= .. %> 改成 <%# ... %>
    并且在Page_Load方法中加上:Page.Header.DataBind(); 或者:在Head中再包裹一个PlaceHolder,把Head中的内容放到PlaceHolder中http://stackoverflow.com/questions/778952/the-controls-collection-cannot-be-modified-because-the-control-contains-code-bl
      

  8.   


    这没有问题,可以运行。
    另外,没有必要使用 Application 集合,那是 asp (10几年前)的程序写法。定义一个 public static 的变量用于绑定就行了。
      

  9.   


    这没有问题,可以运行。
    另外,没有必要使用 Application 集合,那是 asp (10几年前)的程序写法。定义一个 public static 的变量用于绑定就行了。
    大P神。
      

  10.   


    这没有问题,可以运行。
    另外,没有必要使用 Application 集合,那是 asp (10几年前)的程序写法。定义一个 public static 的变量用于绑定就行了。不可以的呢。
      

  11.   


      <meta name="keywords" content="<%=Application["PageKeywords"]%>" />
        <meta name="description" content="<%=Application["Pagede"] %>" />
    //单引号...
     <meta name="keywords" content=‘<%=Application["PageKeywords"]%>’ />
      

  12.   

    注意前面应该用单引号,具体看下面,还有报错需要加 ValidateRequest ,这样就不会报错并且能用了 比如:<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Index.master.cs" Inherits="Web.Template.Index" ValidateRequest="false" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <strong><span style="color: #FF0000;">    <title> <%=Application["PageTitle"] %></title>
        <meta name="keywords" content='<%=Application["PageKeywords"]%>' />
        <meta name="description" content='<%=Application["Pagede"] %>' /></span></strong>
        <link href="../CSS/Index/Index.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
     
     </div>
        </form>
    </body>
    </html>