I understand a lot of the benefits of the convention over configuration approach of ASP MVC. That said, I would like to attempt to build an ASP MVC-based site using an configuration-based a approach and with route attributes.
Effectively, I'd like to have all my Controllers in the root of the project (not nested below the 'Controllers' folder) and the views beside then (no nested below the views folder).
e.g. within the root folder something like:
Posts.cs (Controller) - would have methods that's would map to routes via attributes
Posts.cshtml (View)
I've been searching and surprising have found very little on the topic.
For example i've got following controller in my root directory (more.cs)
public class More : Controller
{
[Route("more")]
public ActionResult Index()
{
return View("~/more.cshtml");
}
}
And I'm calling this in RouteConfig.cs
routes.MapMvcAttributeRoutes();
But generates a resource cannot be found error
Again - I am not looking for WHY I would not want to do this... i understand the benefits of convention... but HOW I could do it if i wanted to (rightfully or wrongly).