我的观点:
<form class="form-horizontal" role="form" method="get" >
<div class="form-group">
<input type="password" id="inputpassword" name="inputpassword" placeholder="@ViewBag.PlaceHolder1st">
</div>
<div class="form-group">
<input type="password" id="inputPasswordconfirm" name="inputPasswordconfirm" placeholder="@ViewBag.PlaceHolder1st">
</div>
<div class="form-group">
<button type="submit" id="btnSave" class="btn btn-info" data-loading-text=@ViewBag.ButtonLoading>
<span class="glyphicon glyphicon-share-alt"></span>
@ViewBag.Button
</button>
</div>
</form>
我的控制器:
[HttpGet]
[Route("reset_password/{userid}/{language}")]
public ActionResult PasswordReset(string userid, string language, string pass, string inputpassword, string inputPasswordcomfirm)
{
// Do stuff
return View();
}
当我按下按钮时,获取输入对象的值......很好..但是,有两件事:
最后,我的网址显示密码值
本地主机:61443 / reset_password / D1171DAC3EA22AAF2FB133B30FA32AAD23B73E7232A56BFC / EN控件inputPassword = 1234&安培; inputPasswordconfirm = 1234
如何从网址隐藏我的密码值或更改我获取值的方式不要在网址中显示我的密码? (没有会议)
如何更改按钮单击事件以重定向到同一控制器中的其他方法? (考虑到我使用“Route”属性)。我尝试将action属性添加到Form标记,将“method”属性更改为Form标记,但是即使仍然输入“PasswordReset”方法也不起作用。
答案 0 :(得分:0)
如果您将表单方法更改为POST而不是GET,则响应将不在URL中,而是通过HTTP_REQUEST变量传递到服务器。
答案 1 :(得分:0)
答案 2 :(得分:0)
你可以尝试这样的事情。
查看
@model ResetPasswordViewModel
@{
ViewBag.Title = "Reset password";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ResetPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="form-group">
@Html.LabelFor(m => m.UserId, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.UserId, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Inputpassword, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.Inputpassword, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.InputPasswordcomfirm, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.InputPasswordcomfirm, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Language, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.Language, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Reset" />
</div>
</div>
}
<强>模型强>
public class ResetPasswordViewModel
{
public string UserId { get; set; }
public string Language { get; set; }
public string Pass { get; set; }
public string Inputpassword { get; set; }
public string InputPasswordcomfirm { get; set; }
}
行动方法
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
// Do stuff
return View();
}