Esto es lo que mi ayudante HTML se parece a:problema en reconocer ayudantes HTML en asp.net mvc 3 de afeitar
namespace WebApp.WebUI
{
public static class HtmlExtensions
{
public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper, string theme)
{
string publicKey = ConfigurationManager.AppSettings["CaptchaKey_Public"];
string privateKey = ConfigurationManager.AppSettings["CaptchaKey_Private"];
var captchaControl = new Recaptcha.RecaptchaControl
{
ID = "recaptcha",
Theme = theme,
PublicKey = publicKey,
PrivateKey = privateKey
};
var htmlWriter = new HtmlTextWriter(new StringWriter());
captchaControl.RenderControl(htmlWriter);
return new MvcHtmlString(htmlWriter.InnerWriter.ToString());
}
}
}
He intentado usarlo en esta vista:
@{
ViewBag.Title = "Register";
}
@model WebApp.WebUI.ViewModel.RegisterModel
@using (Html.BeginForm("Register", "Auth", FormMethod.Post, new { Id = "ERForm" }))
{
@Html.GenerateCaptcha("clean")
}
Me da este error :
CS1061: 'System.Web.Mvc.HtmlHelper<WebApp.WebUI.ViewModel.RegisterModel>' does not contain a definition for 'GenerateCaptcha' and no extension method 'GenerateCaptcha' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<WebApp.WebUI.ViewModel.RegisterModel>' could be found (are you missing a using directive or an assembly reference?)
¿Qué estoy haciendo mal. Mis espacios de nombres son correctos. Que no aparece en el IntelliSense para @Html
supone que tengo que ser capaz de añadir el espacio de nombres en el y no uso @using WebApp.WebUI ¿verdad? –
¿Alguna vez tuvieron suerte al hacer esto funcionar sin la directiva de uso localmente en la vista de afeitar? Eso funciona para mí, pero aún no puedo hacer que funcione globalmente (sin el @using y solo el @Html.). –
JaJ