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 Adding an Action to a Controller

No data is showing for ComicsBooksController.

In the video he is able to navigate to /ComicBooks/Detail without a 404 issue. But when I go to navigate to my controller link it gives me a 404.

Here is my comic controller:

asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc

namespace ComicBookGallery.Controllers
{
    class ComicsBooksController : Controller
    {
        public string Detail()
        {
            return "Hello from the comics book controller!";
        }
    }
}

Also, an error appears to be showing.

Error:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1002  ; expected  ComicBookGallery    C:\Users\ethan\Documents\Repos\src\ComicBookGallery\ComicBookGallery\Controllers\ComicsBooksController.cs   7   Active

I am going to be looking for the error code in msdn. In the meantime, I would surely love the help!

3 Answers

I am a ding dong. I forgot the "using System.Web.Mvc;" semicolon at the end. No need to answer this anymore!

Just updated the code and get the same error

asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc

namespace ComicBookGallery.Controllers
{
     public  class ComicsBooksController : Controller
    {
        public string Detail()
        {
            return "Hello from the comics book controller!";
        }
    }
}
Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Hello.

You named your controller "ComicsBooksController", so the URL you need to reach is : "/ComicsBooks/Detail". (There's an "s" after Comic)