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 Redirecting to an Action

IssuesController problem return to the Index action method

I have a problem understanding this question. I tried to return(Index); but I think that is wrong. When I checked the compiler, the error was about a using statement.

IssuesController.cs
using System.Web.Mvc;
using IssueReporter.Data;
using IssueReporter.Models;

namespace IssueReporter.Controllers
{
    public class IssuesController : Controller
    {
        private IssuesRepository _issuesRepository;

        public IssuesController()
        {
            _issuesRepository = new IssuesRepository();
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Report()
        {
            var issue = new Issue();

            return View(issue);
        }

        [HttpPost]
        public ActionResult Report(Issue issue)
        {
            if (ModelState.IsValid)
            {
                _issuesRepository.AddIssue(issue);

                return(Index);
            }

            return View(issue);
        }
    }
}

1 Answer

James Churchill
STAFF
James Churchill
Treehouse Teacher

Amy,

If you haven't already, you might try rewatching the video that comes before this code challenge.

https://teamtreehouse.com/library/redirecting-back-to-the-list-page

If you're still unsure of the correct answer after doing that, let me know :)

Thanks, James