第一次学习asp.net核心。
我有一个观点。
在该视图中我正在加载一个html.Partial视图。
在那个局部视图中,我正在调用我的api控制器。
我收到#pragma warning restore 1998错误。
这是我的观点(我希望剥离相关性!)......
@model MyDomain.Services.Models.Account
@{
ViewData["Title"] = "Home Page";
}
<div id="divLogForm" class="modal-dialog" style="display:none;position:absolute; ">
<div style="background-color: #fefefe;margin: auto;padding: 20px;border: 1px solid #888;">
<div class="modal-header">
<button id="btnClose" type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="hdrTitle">LogIn</h4>
</div>
<div class="modal-body">
@await Html.PartialAsync( "~/Views/Segments/_Registration.cshtml")
</div>
</div>
</div
这是我的_Registration view ....
@model MyDomain.Services.Models.Account
<div class="row" style="display:none" id="divRegistration">
<div class="col-xs-6">
<div class="well">
<div class="form-group">
<label asp-for="Registration.EmailAddress" class="control-label"></label>
<input type="text" class="form-control" id="EmailAddress" name="EmailAddress" value="" required="" title="Please enter you username" placeholder="example@gmail.com">
<span class="help-block"></span>
</div>
<div class="form-group">
<label asp-for="Registration.Password" class="control-label">Password</label>
<input type="password" class="form-control" id="Password" name="Password" value="" required="" title="Please enter your password">
<span class="help-block"></span>
</div>
<div class="form-group">
<label asp-for="Registration.ConfirmPassword" class="control-label"></label>
<input type="password" class="form-control" id="ConfirmPassword" name="ConfirmPassword" value="" required="" title="Please confirm your password">
</div>
<div id="registerErrorMsg" class="alert alert-error hide">Invalid registration</div>
<a asp-area="" asp-controller="Account" asp-action="Register" class="btn btn-success btn-block">Register</a>
</div>
</div>
<div class="col-xs-6">
<p class="lead">Already Registered?</p>
<p><a onclick="showLogInPage();" class="btn btn-info btn-block">LogIn</a></p>
</div>
</div>
这些是我的模特:
public class Account
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long AccountId { get; set; }
[Display(Name = "Email Address")]
[Required]
[StringLength(60, MinimumLength = 3)]
public string EmailAddress { get; set; }
[NotMapped]
public Registration Registration { get; set; }
}
public class Registration
{
[NotMapped]
[Display(Name = "Email Address")]
[Required]
[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address not found")]
[StringLength(60, MinimumLength = 3)]
public string EmailAddress { get; set; }
[NotMapped]
[Required]
[RegularExpression(@"(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,32}$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).{8,32}$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,32}$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,32}$)?", ErrorMessage = "Password should at length of 5 and include upper/lower letter and contain a number")]
[StringLength(30, MinimumLength = 5)]
[DataType(DataType.Password)]
public string Password { get; set; }
[NotMapped]
[Required]
[RegularExpression(@"(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,32}$)?(^(?=.*\d)(?=.*[a-z])(?=.*[@#$%^&+=]).{8,32}$)?(^(?=.*\d)(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,32}$)?(^(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,32}$)?", ErrorMessage = "Password should at length of 5 and include upper/lower letter and contain a number")]
[StringLength(30, MinimumLength = 5)]
[Display(Name = "Confirm Password")]
[DataType(DataType.Password)]
[Compare("Password", ErrorMessage = "Confirm password doesn't match, Type again!")]
public string ConfirmPassword { get; set; }
}
这是我的控制者:
public class AccountController : Controller
{
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Register([Bind("EmailAddress,Password")] Registration registration)
{
if (ModelState.IsValid)
{
//do some thing
}
}
}
当我点击注册按钮时,我得到了这个:
我在这个控制器方法中设置了一个断点但它永远不会被击中。
我打算发布“显示赞美来源”的结果,但它非常详细,但在检查时我没有看到任何明显的东西可以帮助我。
所以......我确信我在这里做咆哮,我希望我在过去两年没有签订过Windows桌面表格的合同(不得不经济衰退,需要现金:))因为我似乎有忘记了关于网络的一切......
此外,我如何在诊断此编译指示错误时进行(以供将来参考)?
Windows日志中没有任何内容。我的IDE中没有任何警告供我调查。
欢迎所有建议。
由于