剃刀模板内的分析器错误

时间:2015-09-02 07:52:01

标签: asp.net-mvc razor visual-studio-2013

enter image description here我试图在我的项目中使用Captcha,但是使用以下代码获取解析器错误...努力消除它

@{MvcCaptcha registrationCaptcha = CaptchaHelper.GetRegistrationCaptcha(); }
@if (!registrationCaptcha.IsSolved)
{
    <div class="form-group">
        <div class="col-md-offset-4 col-md-8">
            @Html.Captcha(registrationCaptcha)
        </div>
        @Html.Label("Retype the code", new { @class = "col-md-4 control-label", @for = "CaptchaCode" })
        <div class="col-md-8">
            @Html.TextBox("CaptchaCode", null, new { @class = "form-control captchaVal" })
        </div>
    </div>
}

解析器错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

设法纠正它

            MvcCaptcha registrationCaptcha = CaptchaHelper.GetRegistrationCaptcha();  

            if (!registrationCaptcha.IsSolved)
            {
                <div class="form-group">
                    <div class="col-md-offset-4 col-md-8">
                        @Html.Captcha(registrationCaptcha)
                    </div>

                    @Html.Label("Retype the code",
              new { @class = "col-md-4 control-label", @for = "CaptchaCode" })

                    <div class="col-md-8">
                        @Html.TextBox("CaptchaCode", null,
                  new { @class = "form-control captchaVal" })
                    </div>
                </div>
            }