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 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
231,268 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