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 trialCody Tapp
9,667 PointsStill receiving parameter error after casting the id parameter
During the video. I added id.Value to make id an explicit cast so the website will not throw an error. However, it still does. Here is my source code.
(Disregard WebApplication1, that is the name that I've been using for the namespace as I can't figure out how to delete the original one that I messed up on before.
using WebApplication1.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WebApplication1.Data;
namespace WebApplication1.Controllers { public class ComicBooksController : Controller {
private ComicBookRepository _comicBookRepository = null;
public ComicBooksController()
{
_comicBookRepository = new ComicBookRepository();
}
public ActionResult Detail(int? id)
{
if (id == null)
{
return HttpNotFound();
}
var comicBook = _comicBookRepository.GetComicBook(id.Value);
return View(comicBook);
}
}
}
1 Answer
Steven Parker
231,198 PointsFor those of us who don't happen to be working on the same project, it helps if you make a snapshot of your workspace and post the link to it here.