C# ASP.NET MVC Forms Creating a Basic Form Adding a POST Action Method

Tyler Rodriguez
Tyler Rodriguez
7,136 Points

I can't seem to figure out what my error is. What are we supposed to do besides decorate the method and add parameters?

Are we supposed to use the ViewBag property?

IssuesController.cs
using System.Web.Mvc;

namespace IssueReporter.Controllers
{
    public class IssuesController : Controller
    {
        [HttpPost]
        public ActionResult Report(string name, string email, string departmentId,
        string severity, string reproducible, string descriptionOfProblem)
        {
            return View();
        }
    }
}
Report.cshtml
@{
    ViewBag.Title = "Report an Issue";
}

<h2>@ViewBag.Title</h2>

<form method="post">

    <div>
        <label for="Name">Name</label>
        <input type="text" id="Name" name="Name" />
    </div>

    <div>
        <label for="Email">Email</label>
        <input type="text" id="Email" name="Email" />
    </div>

    <div>
        <label for="DepartmentId">Department</label>
        <input type="text" id="DepartmentId" name="DepartmentId" />
    </div>

    <div>
        <label for="Severity">Severity</label>
        <input type="text" id="Severity" name="Severity" />
    </div>

    <div>
        <label for="Reproducible">Reproducible</label>
        <input type="text" id="Reproducible" name="Reproducible" />
    </div>

    <div>
        <label for="DescriptionOfProblem">Description of Problem</label>
        <textarea id="DescriptionOfProblem" name="DescriptionOfProblem"></textarea>
    </div>

    <button type="submit">Save</button>

</form>

1 Answer

Steven Parker
Steven Parker
148,894 Points

The instructions say to "add another action method...", it's important not to change the one initially provided.

Otherwise, it looks like you'll have it. :+1: