haacked / routemagic

Utility Library to get the most out of ASP.NET Routing.
MIT License
186 stars 46 forks source link

Redirect routes are registered without name, so @Url.RouteUrl("name"...) fail #22

Open spshenychnyy-mechanicadvisor opened 5 years ago

spshenychnyy-mechanicadvisor commented 5 years ago

Redirect() call ignores the name with which "old" rout is being registered in passed Func. Instead it takes just the result Route and calls routes.Add((RouteBase) redirectRoute); (without name argument).

This leads to situation that if some page contains @Url.RouteUrl("name"...) link, it fails to render due to absense of named route.

PS: I need many routes to be redirected to home page, so I have code like var homePage = routes.MapRoute(...); routes.Redirect(...).To(homePage); routes.Redirect(...).To(homePage); ...

I would like to avoid registering each of the deleted routes separately since it looks redundant...