★★★.NET 在meta标签中使用表达式设置页面的关键字

在aspx文件中 给meta标签的属性复制是不能直接使用 表达式的

错误的写法:

<meta name="keywords" content="<%=newsType.Nt_KeyWords %>"/>  无法解析

正确的写法:

<meta name="keywords" content=<%=""" +newsType.Nt_KeyWords %>"/>
<meta name="description" content=<%=""" +newsType.Nt_Description %>" />

 造成上面的原因是因为我们新建aspx页面时head标签自动添加了一个属性 runat="server"

<head id="Head1" runat="server">

去掉runat属性,则可以直接使用表达式了,没有上面的顾及。

<meta name="keywords" content="<%=C.city %>楼盘团购,<%=C.city %>在售楼盘团购" />
<meta name="description" content="团立方以优质的服务为您提供最及时全面的<%=C.city %>楼盘团购信息" />
原文地址:https://www.cnblogs.com/gosky/p/4089054.html