I thought this would be fairly easy, but I'm totally baffled.
I want one controller's views to be at the root level of the application, rather than in a subdirectory for that controller, but I cannot figure it out.
I'd like to have these two urls:
/Info - This should action "Info" on controller "Home"
/Admin/ - This should be action "Index" (default) on controller "Admin"
So far no matter what I've tried, the first route will end up catching both. I can't seem to separate the two.
That Info page doesn't even need a controller, it' static, but I do want to use a master page. There may be a much easier way to pull this off, but I haven't figured that out either.
All I can think of that would work, would be to create an Info controller, and move Views/Home/Info to Views/Info/Index, but that has a certain smell to it.
I was able to do this in rails using:
map.connect ':controller/:action/:id'
map.connect ':action', :controller => 'home'
You just need proper routes. In your case:
routes.MapRoute(
"Info",
"Info",
new { controller = "Home", action = "Info" }
routes.MapRoute(
"Admin",
"Admin",
new { controller = "Admin", action = "Index" }
But i recommend you this approach.
If you need to change default physical location of views/partialviews,
check out how to create custom view engines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With