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

Unable to complete this challenge.

I tried using Redirect method, but I'm getting error as "The type or namespace name `Redirect' could not be found. Are you missing an assembly reference?".

VideoGamesController.cs
using System.Web.Mvc;
using System;
namespace Treehouse.Controllers
{
    public class VideoGamesController : Controller
    {
        public ActionResult Detail()
        {
            return new Redirect("/");
        }
    }
}

1 Answer

Remove the "new" from your return Redirect. You don't need to instantiate an object.

Hi Edward, I tried your suggestion but I got Error "The name `Redirect' does not exist in the current context".

The challenge simulator apparently doesn't support the Redirect using the Challenge Link at the top of the page. I'm fairly sure that the code you have above will work fine in an Mvc application after you remove the "new" before Redirect. If you have a specific challenge that's not working please directly me and I'll see what I can figure out.