Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Issue with ActionName in challenge

Not sure what I am missing... I am receiving back an error with the ActionName that is causing the code not to compile. Any help would be greatly appreciated!

IssuesController.cs
using System.Web.Mvc;

namespace IssueReporter.Controllers
{
    public class IssuesController : Controller
    {
        public ActionResult Report()
        {
            return View();
        }

        [ActionName("Report")] 
        [HttpPost]
        public ActionResult ReportSubmit(
            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
231,198 Points

:point_right: Try removing the ActionName decorator and naming the method Report.

It can safely share the same name as the "Get" method since they take different arguments.

Also check your arguments list to be sure each name begins with a lower-case character.

Ahh, that did it! Thanks! Had to change the name of the public ActionResult ReportSubmit( to public ActionResult Report(, remove the ActionName, and make 'Reproducible' become 'reproducible' and I was able to complete. I really appreciate your response. Thanks!