1

I m writing an httpModule to intercept the request that is coming to ASP.NET MVC application. Is there an easy way to figure out what part of the URL constitutes area, controller, action and the actual value.

e.g. www.mysite.com/category/products/GetDetails/101

category: area products: controller GetDetails: action 101: productId

Is there an easy way to get back from RouteEngine or something...

akshay
  • 21
  • 3

2 Answers2

0

ControllerContext.RouteData

Should help you out, the answer here too.

Community
  • 1
  • 1
Daniel Elliott
  • 22,647
  • 10
  • 64
  • 82
  • Awesome Daniel thanks for the direction. So the data is available in HttpContext.Current.Request.RequestContext.RouteData – akshay Oct 06 '11 at 19:41
0

A route like this might work:

routes.MapRoute(
            "category", // Route name
            "~/category/products/getdetails/{ProductId}", // URL with parameters
            new { controller = "products", action = "getdetails" },
            new { ProductId = "\\w+" });

This will map the ProductId as a variable to the getdetails action of your products controller.

endyourif
  • 2,186
  • 19
  • 33