How does MVC handle the submit button in my code? I have a controller named ArticleController which should handle it, but I can't figure out how.
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Article</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Text, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Text, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Text, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default"/>
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
The controller looks like this:
namespace Decision.Controllers
{
public class ArticleController : Controller
{
// GET: Article
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult Create()
{
var article = new ArticleController();
var home = new HomeController();
return View(home);
}
/*[HttpPost]
public ActionResult Create(Article article)
{
entities.Article.AddObject(article);
entities.SaveChanges();
return Redirect("/");
}*/
}
}
Which method handles the submit button when clicked?