C#C
C#3y ago
no >> body

✅ ASP.NET Core form with two submit buttons

I have a form

    <form asp-route="MultiFactorAuthenticate">
        <div class="space-y-7">
            <div class="text-lg">
                Enter 6-digit verification code sent to your mobile
            </div>
            <input type="hidden" asp-for="@Model.Command.RedirectTo"/>
            <input type="hidden" asp-for="@Model.IsRegistrationVerification"/>

            <div id="otp-section" class="form-group text-center mb-5">
                <input asp-for="@Model.Command.OtpString"
                       type="text"
                       title="Otp"
                       placeholder=""
                       autocomplete="one-time-code"
                       maxLength="6"
                       inputmode="numeric"
                       autofocus
                       class="form-input text-xl appearance-none numeric-plain"/>
            </div>
            <div class="text-center mb-5">
                <button id="verify" type="submit" class="btn-control with-loader">
                    Verify
                </button>
            </div>
            <div class="text-center font-lg">
                Didn't receive the code?<br/>
                <button type="submit" class="font-medium text-blue-500 hover:text-blue-400" asp-page-handler="ResendCode">Send code again</button><br/>
            </div>
        </div>
    </form>

The problem with this code is next:
  1. I'm trying to log in, login requires sms code. The application sends me a code
  2. I click "Send code again", and application generates a new code and sends it to me
  3. I enter the second code and click Verify button, but the application calls ResendCode handler and sends me a new code again.
Any idea why it can happen?
Was this page helpful?