ASP.NET MVC2母版页 - 服务器端脚本不渲染,第一架被转义 [英] ASP.NET MVC2 Master Page - Server side script not rendering, first bracket being escaped

查看:109
本文介绍了ASP.NET MVC2母版页 - 服务器端脚本不渲染,第一架被转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我作为一个模板,让我来定义每页的meta标签母版页。我的母版页中需要包含的元信息的模型,这里是什么,我试图做下面的一个例子:

I have a master page which I am using as a template to allow me to define meta tags per page. My master page takes in a model which contains the meta information, here is an example of what I am trying to do the following:

<meta name="description" content="<%= Model.description %>" />
<meta name="keywords" content="<%= Model.keywords %>" />

然而,当我检查HTML一旦呈现页面我得到这个:

However, when I check the HTML once the page is rendered I get this:

<meta name="description" content="&lt;= Model.description %>" />
<meta name="keywords" content="&lt;= Model.keywords %>" />

如果我从内容中删除外引号例如内容= LT;%= Model.description%GT; 它呈现的数据。它似乎并不喜欢周围的引号。

If I remove the outer quotation marks from the content e.g. content=<%= Model.description %> it renders the data. It doesn't seem to like the surrounding quotation marks.

这是与母版页中的错误?如果是这样,这将是我们的最佳替代的解决方法?如果不是这样,我是什么做错了吗?

Is this a bug with the master pages? If so, what would be the best alternative workaround for this? If not, what am I doing wrong?

推荐答案

我曾经看到过,这是一个痛苦。也许你有一个RUNAT =在你的头标记类似这样的断绝属性:

I have seen that before and it is a pain. Probably you have a runat="sever" attribute in your head tag like this:

<head runat="server">

如果你只是做它:

<head>

那么你不应该看到此行为。

then you should not see this behavior.

这篇关于ASP.NET MVC2母版页 - 服务器端脚本不渲染,第一架被转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆