我试图在视图中显示错误消息。您能否建议我正确的方法来做到这一点。我正在考虑动态添加数据注释,但找不到任何解决方案。
谢谢
[HttpPost]
public ActionResult AddBook(BooksModel booksModel)
{
try
{
booksModel.Account = _bookRepository.BookDetails(booksModel.Title,booksModel.RefCode, booksModel.DontHaveRefCode);
}
catch (FaultException faultException)
{
switch (faultException.Code.Name)
{
case "exc1":
// Show Error Message Here
return View("AddBook", booksModel);
default:
break;
}
}
return View("ConfirmBook", booksModel);
}