提问人:Samithra niroshana 提问时间:11/8/2020 最后编辑:JackdawSamithra niroshana 更新时间:11/29/2020 访问量:244
如何在远程模型验证中防止此路由错误 ASP.NET Core
How to prevent this route error in remote model validation ASP.NET Core
问:
我正在尝试使用此远程验证属性验证电子邮件,但不断收到此错误。有谁知道确切的原因?
public class StudentVm
{
public string Id { get; set; }
[Required]
public string Name { get; set; }
[Remote( "Test", "Validation", HttpMethod = "POST", ErrorMessage = "Invalid Email.")]
public string Email { get; set; }
}
//The validation controller
[Route("Validation/[action]")]
public class ValidationController : Controller
{
[HttpPost]
public async Task<IActionResult> Test(string Email)
{
return Json(false);
}
}
错误
处理请求时发生未处理的异常。 TypeLoadException:无法从程序集“System.Web,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”加载类型“System.Web.Routing.RouteValueDictionary”
答: 暂无答案
评论
[Route("Validation/[action]")]
[Route("[controller]")]
[HttpPost]
[HttpPost, Route("test")]
/Validation/test
"[email protected]"
string email
[FromBody] StudentVm student