doo*_*deb 23 asp.net meta-tags content-pages
我有几个主页面上挂着几个内容页面.我需要在其中一个内容页面添加刷新元标记,但我看不到我能在哪里做到这一点.
任何帮助将非常感激.
Ple*_*eun 21
没有尝试刷新,但一般情况下你可以添加这样的元标记:
var keywords = new HtmlMeta { Name = "keywords", Content = "one,two,three" };
Header.Controls.Add(keywords);
Run Code Online (Sandbox Code Playgroud)
更新:这是可能的.查看Rick Strahl http://www.west-wind.com/weblog/posts/2006/Aug/04/No-more-Meta-Refresh-Tags
DOK*_*DOK 16
此页面解释了新功能:ASP.Net 4为页面添加了2个与Meta标签相关的新属性.它们可用于为关键字和描述设置元标记.
您可以在后面的代码中设置它们:
Page.MetaKeywords = "keyword1, keyword2, keyword3";
Page.MetaDescription = "Example of new meta tag support in ASP.Net 4";
Run Code Online (Sandbox Code Playgroud)
你也可以在@Page指令中设置:
<%@ Page Language="C#" AutoEventWireup="true"
MetaKeywords="keyword1, keyword2, keyword3"
MetaDescription="Example of new meta tag support in ASP.Net 4"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
Run Code Online (Sandbox Code Playgroud)
这些方法中的任何一个的输出都会使html类似于以下内容:
<!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>
<title>
ASP.NET 4 Meta Tag Support
</title>
<meta name="description" content="Example of new meta tag support in ASP.Net 4" />
<meta name="keywords" content="keyword1, keyword2, keyword3" />
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
小智 5
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Title of page";
HtmlMeta tag = new HtmlMeta();
tag.Name = "description";
tag.Content = "description of page";
Header.Controls.Add(tag);
HtmlMeta tagKeyword = new HtmlMeta();
tagKeyword.Name = "keywords";
tagKeyword.Content = "keywords of page";
Header.Controls.Add(tagKeyword );
}
Run Code Online (Sandbox Code Playgroud)
(来源网址)
归档时间: |
|
查看次数: |
79086 次 |
最近记录: |