I want to return to same page with error message along with query string when the model is invalid in post operation

My code is here

public ActionResult Action1(string Key)
{

    // do something
}

[HttpPost]
public ActionResult Action1(Model user)
{
    if (ModelState.IsValid)
                {
    // do some stuff here
    }
    else
     // redirect to same page with query string key and also error message
}

Please suggest the line i need to add when the model is invalid to stay in the same page by showing the error message

Related posts

Recent Viewed