내 프로젝트의 System.Web.Mvc에 내 도우미를 추가했으며 기본 asp.net MVC 뷰 엔진과 함께 작동하도록했습니다.사용자 정의 HTML 도우미가있는 Spark View Engine
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?)'
어떻게하면 추가 헬퍼를 볼 수 있습니까?
편집 : 나는 또한
수신 된 오류 "HtmlHelper는 네임 스페이스가 아닌 유형입니다." – jdiaz