I've solved it, by using the WAF.Presentation.Web.Captcha.GetCaptchaBitmap function and created a new Html helper for it.
The helper method:
public static MvcHtmlString CaptchaImage(this HtmlHelper helper, string captchaAnswer, int width, int height)
{
var captchaImage = WAF.Presentation.Web.Captcha.GetCaptchaBitmap(captchaAnswer, height, width, System.Drawing.Color.Gray, System.Drawing.Color.LightSlateGray, System.Drawing.Color.White, 35);
var imageBase64 = Convert.ToBase64String(captchaImage);
var imageSrc = string.Format("data:image/png;base64,{0}", imageBase64);
var builder = new TagBuilder("img");
builder.MergeAttribute("src", imageSrc);
builder.MergeAttribute("alt", "Captcha image");
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}
I set the captcha answer in the ViewBag and in the view I can use:
@Html.CaptchaImage((string)ViewBag.CaptchaAnswer, 150, 50)