Asp.net web api 添加ModelError MVC Web api 5后CSS未正确加载

Asp.net web api 添加ModelError MVC Web api 5后CSS未正确加载,asp.net-web-api,asp.net-mvc-5,Asp.net Web Api,Asp.net Mvc 5,我们正在使用绑定,在添加ModelError MVC Web api 5后CSS没有正确加载 以下是我们在web api控制器中的代码: string errorMessage = (string)TempData["errorMsg"]; if (!string.IsNullOrEmpty(errorMessage)) { ModelState.Add

我们正在使用绑定,在添加ModelError MVC Web api 5后CSS没有正确加载 以下是我们在web api控制器中的代码:

                    string errorMessage = (string)TempData["errorMsg"];
                if (!string.IsNullOrEmpty(errorMessage))
                {
                    ModelState.AddModelError("AccountNumber", errorMessage);
                }
实际上,当我们在post-action方法中发布数据时,如果请求中出现任何错误,我们将从post重定向到get-action方法

这是我的html:

<div id="collapseTwo" class="collapse show" role="tabpanel" aria-labelledby="headingTwo">
    <div class="card-block">

        <div class="bank_account">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="row">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">
                    <label>Account Holder Name</label>
                </div>

                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <div class="form-group">
                        @Html.TextBoxFor(model => model.BankAccount.AccountHolderName, new { @class = "form-control", placeholder = "Account Holder Name" })
                        @Html.ValidationMessageFor(model => model.BankAccount.AccountHolderName, "", new { @class = "text-danger holder_name" })
                    </div>
                </div>

            </div>

            <div class="row">
                @Html.EditorFor(model => model.BankAccount)
            </div>

            <div class="row">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">&nbsp;</div>
                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <div class="form-group">
                        <label>
                            @Html.CheckBoxFor(model => model.AgreeWithTermCondtion, new { @class = "term_height" }) I agree with <a class="tmc" id="anch_terms_and_conditions" href="javascript:void(0)">Terms &amp; Conditions </a>
                        </label>
                        @Html.ValidationMessageFor(model => model.AgreeWithTermCondtion, "", new { @class = "text-danger" })
                    </div>
                </div>

            </div>

            <div class="row mt-2">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">&nbsp;</div>
                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <button type="submit" class="btn btn_pay" id="btn_create_dd_plan"> Create Plan </button>

                    @CancellationButtion()
                </div>

            </div>

        </div>
    </div>
</div>

@Html.ValidationSummary(true,“,new{@class=“text danger”})
帐户持有人姓名
@Html.TextBoxFor(model=>model.BankAccount.AccountHolderName,新的{@class=“form control”,placeholder=“账户持有人名称”})
@Html.ValidationMessageFor(model=>model.BankAccount.AccountHolderName,“,新的{@class=“text-danger-holder\u-name”})
@EditorFor(model=>model.BankAccount)
@(model=>model.agreewithtermcondition,new{@class=“term_height”})我同意
@Html.ValidationMessageFor(model=>model.agreeWithTermCondition,“,new{@class=“text danger”})
创建计划
@取消

用以下html替换您的html:

<div id="collapseTwo" class="collapse show" role="tabpanel" aria-labelledby="headingTwo">
    <div class="card-block">
 @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="bank_account">
            <div class="row">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">
                    <label>Account Holder Name</label>
                </div>

                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <div class="form-group">
                        @Html.TextBoxFor(model => model.BankAccount.AccountHolderName, new { @class = "form-control", placeholder = "Account Holder Name" })
                        @Html.ValidationMessageFor(model => model.BankAccount.AccountHolderName, "", new { @class = "text-danger holder_name" })
                    </div>
                </div>

            </div>

            <div class="row">
                @Html.EditorFor(model => model.BankAccount)
            </div>

            <div class="row">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">&nbsp;</div>
                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <div class="form-group">
                        <label>
                            @Html.CheckBoxFor(model => model.AgreeWithTermCondtion, new { @class = "term_height" }) I agree with <a class="tmc" id="anch_terms_and_conditions" href="javascript:void(0)">Terms &amp; Conditions </a>
                        </label>
                        @Html.ValidationMessageFor(model => model.AgreeWithTermCondtion, "", new { @class = "text-danger" })
                    </div>
                </div>

            </div>

            <div class="row mt-2">

                <div class="col-xl-4 col-lg-12 col-md-4 col-12">&nbsp;</div>
                <div class="col-xl-8 col-lg-12 col-md-8 col-12">
                    <button type="submit" class="btn btn_pay" id="btn_create_dd_plan"> Create Plan </button>

                    @CancellationButtion()
                </div>

            </div>

        </div>
    </div>
</div>

@Html.ValidationSummary(true,“,new{@class=“text danger”})
帐户持有人姓名
@Html.TextBoxFor(model=>model.BankAccount.AccountHolderName,新的{@class=“form control”,placeholder=“账户持有人名称”})
@Html.ValidationMessageFor(model=>model.BankAccount.AccountHolderName,“,新的{@class=“text-danger-holder\u-name”})
@EditorFor(model=>model.BankAccount)
@(model=>model.agreewithtermcondition,new{@class=“term_height”})我同意
@Html.ValidationMessageFor(model=>model.agreeWithTermCondition,“,new{@class=“text danger”})
创建计划
@取消