0

First let me be clear I am talking about the independent project of AttributeRouting http://attributerouting.net/ and not the built-in attribute routing.

Take this slightly modified version of their example code:

public class SampleController : Controller
{   
    [GET("Sample")]
    public ActionResult Index() { /* ... */ }
    [POST("Sample")]
    public ActionResult Create() { /* ... */ }
    [PUT("Sample/{id}")]
    public ActionResult Update(string id) { /* ... */ }
}

Suppose that for Update I wanted to have the request PUT Sample/Cheese/Swiss is there any way to inform AttributeRouting that the id parameter should capture "Cheese/Swiss"?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
  • Yes I know I could use the request `PUT Sample/Cheese-Swiss` or similar which I may end up doing, but I'd prefer to able to achieve my original goal here. – Chris Marisic Oct 03 '14 at 13:17
  • Why not `Update(string product, string id)`? and `[PUT("Sample/{product}/{id})]`? Then coalesce it in the method if necessary. – tvanfosson Oct 03 '14 at 13:24
  • @tvanfosson also possible, but what if the id i want is Cheese/Swiss/Block or School/PennState/Program/SoftwareEngineering. I guess I could go the Tuple approach and have X methods that recompose the url and pass it down to a single shared method. My end goal is for targeting rather high levels of dynamicism. – Chris Marisic Oct 03 '14 at 14:05

1 Answers1

1

Wouldn't [PUT("Sample/{*id}")] work? The asterisk means "take the rest".

Kijana Woodard
  • 510
  • 7
  • 17
  • That is not documented on their site and while I'm familiar with that usage from the built-in MVC catch-all routes I was unaware that was relevant to attribute routing. – Chris Marisic Oct 03 '14 at 14:29