I don't know if this was happening in the PR or Beta, but if I create an extension method on HtmlHelper
, it is not recognized in a Razor powered page:
namespace SomeNamespace.Extensions {
public static class HtmlExtensions {
public static string Foo(this HtmlHelper html) {
return "Foo";
}
}
}
I added it to the <Namespaces>
section in Web.config
:
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<!-- snip -->
<add namespace="SomeNamespace.Extensions"/>
</namespaces>
</pages>
But it throws a compile error when trying to view the page:
@Html.Foo()
If I recreate the page with WebForms it works fine. What's the deal?
Workaround
If I include @using SomeNamespace.Extensions
in my Razor view, then it works, but I'd much rather just have it in Web.config