I am new to MVC4. Here I added the ModelState.AddModelError message to display when the delete operation is not possible.
-
The RedirectToAction method returns 302 which causes the client to be redirected. Because of this the ModelState is lost as the redirect is a new request. You could however, use the TempData property which allows you to store a temporary piece of data that is unique to the session. You could then check for this TempData on the other controller and add a ModelState error in that method.
- 热议问题