Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# ASP.NET MVC Basics Controllers Using Action Result Types

Rena Tindle
Rena Tindle
647 Points

I am stuck on task 1 of 1.... not sure how to continue to modify the code, but it is not passing the challenge.

Please help, my code is attached below.

VideoGamesController.cs
using System.Web.Mvc;

namespace Treehouse.Controllers
{
    public class VideoGamesController : Controller
    {
        public ActionResult Detail()
        {
           return new ContentResult()
           {

            return Content= "Welcome to the Video Game Detail page!"
            };

        }
    }
}

2 Answers

Steven Parker
Steven Parker
215,984 Points

There's 3 parts to this task, and I see you've done the first one by changing the return type correctly. So what's left is to "return the result of a call to the base controller's Content method", and to pass "the string literal "Welcome to the Video Game Detail page!" to the Content method".

Issues I notice in this code are:

  • there are two "return" statements instead of one
  • the first one doesn't seem related to the instructions
  • the second one is assigning an undeclared "Content" instead of calling the method with that name
  • the string is being assigned instead of passed as an argument