如题,在beta版中的    
this.Header.Metadata.Add("taye", "value");
不能用了。

解决方案 »

  1.   

    # re: ASP.NET 2.0 backwards compatible? NOT. Here's an obvious one - level 200  
    posted at Tuesday, August 17, 2004 3:32 AM by Anders Norås 
    The head element in the ASP.NET 2.0 page template is by default declared to run at the server. In addition the System.Web.UI.HtmlControls namespace has a new class called HtmlHead defined. When you set the id attribute of the head element to “Head” this becomes a member of your class (which inherits from System.Web.UI.Page). 
    The reason for you not seeing the code defining this member is that ASP.NET 2.0 uses partial classes to separate user defined code from tool generated code. 
    As a result of this you get a member naming conflict when defining an additional member called “Head” typed System.Web.UI.HtmlControls.HtmlGenericControl. To solve your problem using your existing code which I reckon is similar to this: 
    ASPX snippet: 
    <head id="Head" runat="server"> Codebehind snippet: 
    protected HtmlGenericControl Head; 
    private void Page_Load(object sender, System.EventArgs e) 

    HtmlGenericControl meta=new HtmlGenericControl("meta"); 
    meta.Attributes.Add("name","pragma"); 
    meta.Attributes.Add("content","no-cache"); 
    Head.Controls.Add(meta); 
    } Remove the declaration of the “Head” member in the code behind file. Another option is to add your metadata using the Page.Header.Metadata collection like this: 
    Page.Header.Metadata.Add("name", "pragma"); 
    Page.Header.Metadata.Add(“content”,”no-cache”): 
    =====================================================
    调试后得到的结果如下:
    <head><link href="../App_Themes/White/aboutMenu.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/White/Default.css" type="text/css" rel="stylesheet" /><title>
    Untitled Page
    </title><meta name="robots" content="all" /><link rel="Shortcut Icon" href="../favicon.ico" /><meta name="pragm" content="no-cache"></meta><style type="text/css">
    .ctl00_Menu2_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
    .ctl00_Menu2_1 { text-decoration:none; }
    .ctl00_Menu2_2 {  }</style></head>这个是正确的答案么?