Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model WebApplication2.ViewModels.ViewPost
- <form asp-controller="home" asp-action="AddPost" method="post" role="form">
- @Html.EditorForModel(Model)
- <input type="submit" value="Add" />
- </form>
- [HttpPost]
- public IActionResult AddPost(ViewPost post)
- {
- return Content($"Name: {post.name} Post: {post.post}");
- }
- public class ViewPost
- {
- public string name { get; set; }
- public string post { get; set; }
- }
- [HttpPost]
- public IActionResult AddPost(string name, string post)
- {
- return Content($"Name: {name} Post: {post}");
- }
- [HttpPost]
- public IActionResult AddPost(ViewPost model)
- {
- return Content($"Name: {model.name} Post: {model.post}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement