Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. @model WebApplication2.ViewModels.ViewPost
  2.  
  3. <form asp-controller="home" asp-action="AddPost" method="post" role="form">
  4. @Html.EditorForModel(Model)
  5. <input type="submit" value="Add" />
  6. </form>
  7.  
  8. [HttpPost]
  9. public IActionResult AddPost(ViewPost post)
  10. {
  11. return Content($"Name: {post.name} Post: {post.post}");
  12. }
  13.  
  14. public class ViewPost
  15. {
  16. public string name { get; set; }
  17. public string post { get; set; }
  18. }
  19.  
  20. [HttpPost]
  21. public IActionResult AddPost(string name, string post)
  22. {
  23. return Content($"Name: {name} Post: {post}");
  24.  
  25. }
  26.  
  27. [HttpPost]
  28. public IActionResult AddPost(ViewPost model)
  29. {
  30. return Content($"Name: {model.name} Post: {model.post}");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement