我已经使用Individual User Accounts
创建了我的应用程序,我想在其中使用从login
控制器创建的默认register
和Account
页面。
我想在OTP登录页面中实现复选框,为此我在登录页面内编写了JQuery逻辑,该逻辑从AddPhoneNumber
控制器调用Manage
。
我删除了obj和bin文件夹,然后清理了该项目并重建它,但是在web.config <authentication mode="Forms"/>
的这一行中仍然出现错误。
但是奇怪的是,它不起作用并且抛出错误。如果我创建“无身份验证”并执行相同操作,那么它将起作用。请指导我为什么行为不同。
Web.config
<location path="Manage">
<system.web>
<authentication mode="Forms"/>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
管理控制器
// GET: /Manage/AddPhoneNumber
public ActionResult AddPhoneNumber()
{
return View();
}
AddPhoneNumber页面
@model Aayumitra.Models.AddPhoneNumberViewModel
@using (Html.BeginForm("AddPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Add a phone number</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Number, new { @class = "col-md-5 control-label" })
<div class="col-md-7">
@Html.TextBoxFor(m => m.Number, 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-primary" value="Send verification code" />
</div>
</div>
}
登录页面
@using Aayumitra.Models
@model LoginViewModel
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="form-group">
<label for="email">Mobile Number / Email ID</label>
@Html.TextBoxFor(m => m.Email, new { @class = "form-control form-control-sm", placeholder = "Mobile Number / Email ID" })
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<label for="password">Password</label>
@Html.PasswordFor(m => m.Password, new { @class = "form-control form-control-sm password-input", placeholder = "Password" })
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<input type="checkbox" name="remember-password" id="remember-pass-check" onclick="triggerLink()">
<label for="">Login with OTP instead of password</label>
</div>
}
<script type="text/javascript">
function triggerLink() {
debugger;
var theUrl ='@Url.Action("AddPhoneNumber","Manage")';
window.location.href = theUrl;
}
</script>