views:

32

answers:

1

i'd like to map areas like this:

/artists/{artistName}/images
/artists/{artistName}/images/{imageId}
/artists/{artistName}/blogs
/artists/{artistName}/blogs/{blogId}
/artists/{artistName}/albums
/artists/{artistName}/albums/{albumId}

in mvc2, how do i configure my area route and what does my file structure for my area view look like?

thanks.

+1  A: 

I would probably do something like this in your area registration:

Public Overrides ReadOnly Property AreaName() As String
            Get
                Return "Artists"
            End Get
        End Property

Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
     context.MapRoute( _
          "Artists_default", _
          "Artists/{artistName}/{controller}/{id}/{action}", _
                New With {.id = UrlParameter.Optional, .action = "Index"} _
            )
End Sub

Treat images/blogs/albums as your controller. Put the action at the end of the string so that it will stay invisible if each of your examples is only one action.

EDIT: There is a second part to your question :)

By going this route, you will then have a folder structure like this

Areas
  Artists
     Controllers
          ImagesController
          BlogController
          AlbumsController
     Views
          Images
               Index
          Blog
               Index
          Albums
               Index

Your view folder name corresponds to a controller name, the view name itself typically corresponds with an action.

Tommy
ok. i'm guessing but how do i organize my view area?Areas - Artists - Index.aspx - Blogs.aspx - Albums.aspx?
CurlyFro
cool -- thanks for the update
CurlyFro