views:

74

answers:

1

I'm trying to model class and sections of a class and further instances of sections.

so route should be Class/ (Create, Details, Index, Edit) for classes

Then I've a section controller

ClassSection

so I would do

Class/1/ClassSection/ (Create, ... ) since ClassSection without classid is useless

and then further

Class/1/ClassSection/1/Instance

to go to SectionInstance controller

how can I map my routes to conform to this notation

I've tried doing this for class sections

  routes.MapRoute(
      "ClassSections",
      "Class/{classid}/ClassSection/{action}/{id}",
      new { controller = "ClassSection" },
      new { classid = @"d+" }
  );

but I can't generate a proper link from Html.ActionLink in Index action of Class

A: 

You should consider using Areas. It sounds like you're moving in this direction already, but ASP.NET MVC 2.0 has specific support for this.

http://haacked.com/archive/2009/07/31/single-project-areas.aspx

Given the hard constrains "Class" and "ClassSection" in your Url template, I doubt that you need new { classid = @"d+" } to make it a unique match. Try removing that part of your MapRoute and see if that fixes the problem.

Robert Harvey
add this moment I would like to stick with MVC 1.0, also I'm not quite sure how areas would help here since it would be top level separation instead of sub level separation that I want.
AppDeveloper
You say it's not generating a proper link. Is it routing Urls properly?
Robert Harvey
see in comments for question
AppDeveloper