I'm pretty sure I'm just missing something obvious, but here's what's happening.

I added a custom route to my RouteConfig.cs file, as follows:

routes.MapRoute(
    name: "LibraryCategoryList",
    url: "Library/List/{id}",
    defaults: new { controller = "Library", action = "List", id = "Marketing" }
);
routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new[] { "BFRDP.Controllers" }
);

I have a controller named Library with an action List, as follows:

public ActionResult List(string id)
{
    return View(id);
}

My List view is at ~/Views/Library/List.cshtml.

When I try to go to http://localhost:49591/Library/List/Marketing, I get the error:

The view 'Marketing' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Library/Marketing.aspx ~/Views/Library/Marketing.ascx ~/Views/Shared/Marketing.aspx ~/Views/Shared/Marketing.ascx ~/Views/Library/Marketing.cshtml ~/Views/Library/Marketing.vbhtml ~/Views/Shared/Marketing.cshtml ~/Views/Shared/Marketing.vbhtml

(And yes, I do have RouteConfig.RegisterRoutes(RouteTable.Routes); in the Application_Start method in my global.asax.cs file.)

What in the world am I doing wrong?

Thanks!

Laurie

Related posts

Recent Viewed