Avatar ·

How to handle multiple submit buttons in one ASP.NET MVC form?

Hello everyone! I'm new to ASP.NET MVC and ran into a problem when creating a form. I have a view where I need to implement multiple actions: save a draft and publish an article. I want to use one form with two submit buttons, but I don't understand how to determine on the controller side which button was pressed.\n\nHere is my current code:\n\n```csharp\n// Model\npublic class ArticleViewModel\n{\n public int Id { get; set; }\n public string Title { get; set; }\n public string Content { get; set; }\n}\n\n// Controller\n[HttpPost]\npublic ActionResult Save(ArticleViewModel model)\n{\n // Save as draft\n return View(model);\n}\n\n[HttpPost]\npublic ActionResult Publish(ArticleViewModel model)\n{\n // Publish\n return View(model);\n}