我在我的项目中添加了一些我自己的助手到System.Web.Mvc,并让它使用默认的asp.net mvc视图引擎。通过定义像带有自定义HTML助手的Spark View引擎
namespace System.Web.Mvc
{
public static class XSSHelper
{
public static string h(this HtmlHelper helper, string input)
{
return AntiXss.HtmlEncode(input);
}
public static string Sanitize(this HtmlHelper helper, string input)
{
return AntiXss.GetSafeHtml(input);
}
public static string hscript(this HtmlHelper helper, string input)
{
return AntiXss.JavaScriptEncode(input);
}
}
}
助手我把它叫做用<%= Html.h("<h1>some string</h1>") %>
现在,我使用的火花视图引擎我似乎无法得到这个工作。我收到以下错误:
'System.Web.Mvc.HtmlHelper' does not contain a definition for 'h' and no extension method 'h' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)'
如何获取Spark以查看其他帮助?
编辑:我还添加了_global.spark与<using namespace="myApp" />
无济于事
收到的错误“HtmlHelper是一种类型而不是命名空间” – jdiaz 2010-07-28 08:08:52