【发布时间】:2011-11-19 12:16:45
【问题描述】:
我已经为 UrlHelper 编写了一些扩展方法,以便更轻松地加载 , 或标记。但是,它似乎在浏览器中呈现为文字文本。这是我所拥有的:
public static string Script(this UrlHelper helper, string scriptPath)
{
return string.Format(@"<script src=""{0}"" type=""text/javascript""></script>", helper.Content(scriptPath));
}
这是我的 .cshtml 代码:
@section HeadContent
{
@Url.Style("MyStyleName")
@Url.Script("MyScriptName")
@Url.MetaKeywords("My Keywords")
@Url.MetaDescription("Some Description")
}
它在浏览器中显示为&lt;script [etc, etc]&gt;
如果我不使用扩展方法,它会按预期正常工作......我怎样才能让它与我的扩展一起工作?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-3 razor