N0xus
N0xus

Reputation: 2724

Html form adding in hidden redirect button

I'm using umbraco and letting it handle allowing my users to log in. I tried creating my own log in MVC but there is a lot of logic already built upon the old way. And I don't want to spend the time having to re-build it.

There for, I was wondering if there was anyway I could add in a hidden field that would allow the user to be redirected to my home page when the log in using the following form code:

@using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
{
    <legend>Login</legend>

    @Html.ValidationSummary("loginModel", true)

    @Html.TextBoxFor(m => loginModel.Username, new { @class = "form-control", @placeholder = "Username" })
    @Html.ValidationMessageFor(m => loginModel.Username, "", new { @class = "alert-danger", @role = "alert" })
    <br />

    @Html.PasswordFor(m => loginModel.Password, new { @class = "form-control", @placeholder = "Password" })
    @Html.ValidationMessageFor(m => loginModel.Password, "", new { @class = "alert-danger", @role = "alert" })
    <br />

    <button class="btn btn-default">Login</button>

}

Upvotes: 1

Views: 425

Answers (1)

Tim
Tim

Reputation: 4257

You should be able to set the loginModel.RedirectUrl at the point where you're creating it, and then add the following to your form:

@Html.HiddenFor(m => loginModel.RedirectUrl)

Upvotes: 1

Related Questions