Tutorial by Examples

To implement the create functionality we need two actions: GET and POST. The GET action used to return view which will show a form allowing user to input data using HTML elements. If there are some default values to be inserted before user adding any data, it should be assigned to the view mode...
@model ContosoUniversity.Models.Student //The Html.BeginForm helper Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. @using (Html.BeginForm()) { //Generates a hidden form field (anti-for...
By the url ~/Student/Details/5 being: (~: site root, Student: Controller, Details: Action, 5: student id), it is possible to retrieve the student by its id. // GET: Student/Details/5 public ActionResult Details(int? id) { // it good practice to consider that things could go wrong...
// Model is the class that contains the student data send by the controller and will be rendered in the view @model ContosoUniversity.Models.Student <h2>Details</h2> <div> <h4>Student</h4> <hr /> <dl class="dl-horizontal"> <...
// GET: Student/Edit/5 // It is receives a get http request for the controller Student and Action Edit with the id of 5 public ActionResult Edit(int? id) { // it good practice to consider that things could go wrong so,it is wise to have a validation in the controller ...
Is good practice to resist the temptation of doing the delete action in the get request. It would be a huge security error, it has to be done always in the post method. // GET: Student/Delete/5 public ActionResult Delete(int? id) { // it good practice to consider that things...

Page 1 of 1