What is the difference between Routes.Add and MapRoute?

I used MapRoute and wonder a little where Routes.Add is used and in what scenario and how is it different from MapRoute?

+3


source to share


1 answer


MapRoute is just a wrapper around the more generalized Route.Add () This is an extension method, to be precise.

Routing is not MVC and therefore allows you to provide any suitable route. This makes it extremely flexible and allows you to implement your own custom RouteHandlers. I did it again in ASP.Net 3.5 for .aspx pages.



It looks something like this:

routes.Add("Blah", 
   Route("custom/{stuff}", new SecretSauceRouteHandler()))

      

+8


source







All Articles