Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

MR, Ambiguous controller names

leave a comment »

Reading through Phil Haack’s post implication in supporting area in ASP.NET MVC 2 remind me the time I faced the same problem using MonoRail, I believe I had post my solution in the passed but I can’t dig inside my blog entry to get it back.

So here it goes again the trick I used in to fix the problem let assume I had Admin Area & User Area and each has a HomeController I then would create controller file like this:

  • Admin [ Folder ]
    • AdminHomeController.cs
  • User [ Folder ]
    • UserHomeController.cs

Then I need to use ControllerDetails attribute to give these two controller a prefer url

// access with /admin/home/index.castle
[ControllerDetails("home", Area="admin")]
public class AdminHomeController: SmartDispatcherController { ... }

// access with /user/home/index.castle
[ControllerDetails("home", Area="user")]
public class UserHomeController: SmartDispatcherController { ... }

That work for me !


Written by Chorn Sokun

January 13, 2010 at 9:38 pm

Posted in MonoRail, Tips & Tricks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: