I am using Angular to send POST request to save the object in my DB and it works, but after saving information it doesn't return the View()
(or Content, string, nothing):
public class HomeController : Controller
{
private MyDb _db = new MyDb();
[HttpPost]
public ActionResult Test(SomeModel personalInformation)
{
_db.InfoTables.Add(personalInformation);
_db.SaveChanges();
// ??
return View();
}
}
You can't use return View() if you're doing your POST via ajax/Angular. You'll want to use javascript to manage your ng-view or redirect to a new url on success.
Since this is a normal MVC controller, you can post to it with the $http service, then put your view change code in the success function.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加