You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Daniel,
We have faced the following issue:
In MvcApplication.RegisterRoutes we have this route definition:
routes.MapRoute("Default","{controller}/{action}/{id}",new{ controller ="Account", action ="Login", id = UrlParameter.Optional });
And we have an Area with the name (Reports) and this route definition:
context.MapRoute("Reports_default","Reports/{controller}/{action}/{id}",new{ action ="Index", id = UrlParameter.Optional });
On client if we use:
Router.action("Tag","Create",{offeringId: 1})
Its outputting: "/site/Reports/Create/Tag?offeringId=1"
however, it should output: "/site/Tag/Create?offeringId=1"
We fixed this by adding this bit of code after including routeJs script:
Router.route=function(routeValues){for(vari=0,count=this.routes.length;i<count;i++){// fix Area Routes Overriding Default Routeif(this.routes[i].route.defaults.area!=routeValues.area)continue;// endvarurl=this.routes[i].build(routeValues);if(url){returnthis.baseUrl+url;}}throwError('No route could be matched to route values: '+routeValues);};
This will fix the issue
And we are thinking that in case we needed to get the action URL for the Area we will add area=areaName to route parameters like this:
Thanks for the bug report, I'll try to look into this over the weekend. Your approach looks correct to me but I think the logic should be in the Route.prototype.build method instead.
@Daniel15 You're definitely correct. It should be in the build method. For the workaround though, I was unable to get the 'this' object to correctly point at the right route when attempting to override the Route.prototype.build method. We were writing this after the routejs script tags mostly a workaround until a proper fix was in. Thanks for your quick reply.
Hi Daniel,
We have faced the following issue:
In MvcApplication.RegisterRoutes we have this route definition:
And we have an Area with the name (Reports) and this route definition:
On client if we use:
Its outputting: "/site/Reports/Create/Tag?offeringId=1"
however, it should output: "/site/Tag/Create?offeringId=1"
We fixed this by adding this bit of code after including routeJs script:
This will fix the issue
And we are thinking that in case we needed to get the action URL for the Area we will add area=areaName to route parameters like this:
The question is are we following the correct approach here? is there any other way of doing this?
The text was updated successfully, but these errors were encountered: