I have a scenario like i need to display error message which is coming from DB on Edit [GET] request.
I know this can be done if request type is of [POST], but how can we do this in [GET] request.
Same Code:
[HttpGet]
public ActionResult Edit(Int64 ID)
{
tblSample1 model = GetData(ID);
ViewData.ModelState.AddModelError(model.Username, "Invalid Username provided.");
return View("~/Views/Sample1/_Edit.cshtml", model);
}
[HttpPost]
public ActionResult Edit(tblSample1 model)
{
if (ModelState.IsValid)
{
......
......
}
}