Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="/home/showdata" method="post">
- <input type="text" name="arr.username" />
- <input type="text" name="arr.password" />
- <input type="text" name="arr.email" />
- </form>
- public class HomeController : Controller
- {
- [HttpPost]
- public ActionResult ShowData(Array data)
- {
- return Content(data.username + data.password + data.email);
- }
- }
- public ActionResult ShowData(Array data)
- public ActionResult ShowData(YourModelNameHere data)
- public class YourModelNameHere
- {
- public string username {get; set;}
- public string password {get; set;}
- public string email {get; set;}
- }
- <form action="/home/showdata" method="post">
- <input type="text" name="username" />
- <input type="text" name="password" />
- <input type="text" name="email" />
- </form>
- public class HomeController : Controller
- {
- [HttpPost]
- public ActionResult ShowData(FormCollection data)
- {
- string username=data.GetValues("username")[0];
- string password=data.GetValues("password")[0];
- string email=data.GetValues("email")[0];
- return Content(username + password + email);
- }
- }
- public class SampleViewModel {
- public int Id { get; set;}
- public string Name { get; set; }
- }
- public IHttpActionResult SampleActionMethod(SampleViewModel model) {
- if (!ModelState.IsValid) {
- return BadRequest();
- }
- var sampleDbModel = new SampleDatabaseModel() {
- FullName = model.Name,
- ProductId = model.Id,
- // ... some other properties ...
- };
- // ... Save the sampleDbModel ...
- return Ok(); // .. or Created ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement