daveharney (5) [Avatar] Offline
#1
Very good explanation of "Routing" - I definitely learned aspects of routing that I hadn't read elsewhere. Couple of comments:

Page 127 - how did View become DetailedView?

Page 131 - confusing - I assume a misprint or I didn't get the concept - why did USD remain constant?:

{controller}/{currency=USD}/{action=view}
I have actually added two default values here, so we could map any of the following URLs:
• /rates – controller=rates, action=view, currency=USD
• /rates/GBP – controller=rates, action=view, currency=USD
• /rates/USD/edit – controller=rates, action=view, currency=USD
• /currencies – controller=currencies, action=view, currency=USD
Andrew Lock (4) [Avatar] Offline
#2
Hi Dave,

Thanks for your comments as always.

daveharney wrote:
Page 127 - how did View become DetailedView?


This was a bit of a poor example, as it required a) default values that I hadn't covered at that point, and b) I didn't show you the complete route template at that point.

I will fix this example in an update to the MEAP, but for completeness, this is the routes I had in mind. Note that the final route has a default value of DetailedView, which is where that action comes from

routes.MapRoute(
  name: "photos",
  template: "Photos/{action}/{id?}"
  default: new { controller = "photos" });

routes.MapRoute(
  name: "default",
  template: "{controller}/{action}/{id?}");

routes.MapRoute(
  name: "detailed_view",
  template: "Person/View/{name}"
  default: new { controller = "person", action ="DetailedView" });



daveharney wrote:
Page 131 - confusing - I assume a misprint or I didn't get the concept - why did USD remain constant?:

{controller}/{currency=USD}/{action=view}

I have actually added two default values here, so we could map any of the following URLs:

• /rates – controller=rates, action=view, currency=USD
• /rates/GBP – controller=rates, action=view, currency=USD
• /rates/USD/edit – controller=rates, action=view, currency=USD
• /currencies – controller=currencies, action=view, currency=USD


You are completely correct, that was a typo, it should have been GBP in the second example (and the third actually!):

{controller}/{currency=USD}/{action=view}

• /rates – controller=rates, action=view, currency=USD
• /rates/GBP – controller=rates, action=view, currency=GBP
• /rates/USD/edit – controller=rates, action=edit, currency=USD
• /currencies – controller=currencies, action=view, currency=USD

Thanks again
Andrew