2

I get a URL string (not the current route) in my action, I want to know how my routes definitions will parse the URL into Area, Controller and Action

example:

"http://website.com/Selling/Products/UpdateProduct/2"

area == "Selling"
controller == "Products"
action == "UpdateProduct"

I saw this answer from 2-12-2009 with a way how to do it, but it's verbose:
it creates HttpRequst, HttpResponse, HttpContext and HttpContextWrapper! for a simple operation, that doesn't really need HTTP context environment.

Is there a better way today with Asp.Net-Mvc3 ?

Community
  • 1
  • 1
gdoron
  • 147,333
  • 58
  • 291
  • 367

2 Answers2

1

Check out Phil Haack's RouteDebugger.

Akos Lukacs
  • 2,007
  • 1
  • 16
  • 21
1

Is there a better way today with Asp.Net-Mvc3 ?

No, the answer you saw is actually the way to go.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • -1 I think it's not self explaining answer, what do you mean? – hackp0int Jan 12 '12 at 08:14
  • @IamStalker, I mean that the answer that the OP has linked to in his question is the way to go if you want to parse a string into its constituent elements. I also mean that even if this answer dates from 2-12-2009 it is still valid today and that there are no new classes in ASP.NET MVC 3 that allow you to do this. Sorry if my answer wasn't clear enough. – Darin Dimitrov Jan 12 '12 at 08:16