ASP.NET MVC Route definition DSL

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Just had an interesting idea… wouldn’t it be cool to be able to define ASP.NET routes via DSL (Ayende got me hooked up on the idea).

As Ayende mentions, making the idea work is quite simple, check out his blog posts about it:

http://www.ayende.com/Blog/category/547.aspx


But doing something serious with it takes a little bit more work:

http://www.ayende.com/Blog/archive/2007/12/13/Requirements-of-a-DSL-engine.aspx


But before I complicate myself out of doing this, consider this idea. Instead of these route definitions (pictures from ScottGu’s blog):

route1

route2

route3 

route4

route5


Think if you could define them in Routes.boo with something like:


Route “[controller]/[action]/[id]“:
    Defaults:
        action “Index”, id null

Route “Default.aspx”:
    Defaults:
        controller “Home”, action “index”, id null

Route “Search”
    Defaults:
        controller “Search”, action “index”

Route “Search/[query]“
    Defaults:
        controller “Search”, action “results”

Route “Products/Detail/[id]“
    Defaults:
        controller “Products”, action “Detail”
    Validation:
        id “\d{1,8}”

 

What do you think?

Ill try Ayende’s Rhino.DSL one of these days and take a crack at it… maybe something useful will come of it (or at least some new knowledge :))


Cheers!


Filed under: ASP.NET MVC, DSL
Written on: 13 Dec 2007 ·

kick it on DotNetKicks.com

Leave a Reply