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
I am attempting to use your LowercaseDashedRouting utility to make our URLs more SEO friendly. I am struggling with the configuration of the routes. We have a site that uses Areas, but also has a "root Area" (controllers and views that are not in an Area). We are using ASP.NET MVC 4 with Razor.
Here is how I have set up the "root Area" (/App_Start/RouteConfig.cs):
LowercaseDashedRoute defaultRoute = new LowercaseDashedRoute(
url: "{controller}/{action}/{id}",
defaults: new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional }),
constraints: null,
dataTokens: new RouteValueDictionary(new { namespaces = new[] { "ReiWeb.Controllers" } }),
routeHandler: new DashedRouteHandler()
);
routes.Add(defaultRoute);
(Note: I need to specify "namespaces" here because we have Home controllers for each area including the "root area")
Here is how I have set up each of our Areas (this is for our StudentPortal area at /Areas/StudentPortal/StudentPortalAreaRegistration.cs):
LowercaseDashedRoute areaDefaultRoute = new LowercaseDashedRoute(
url: "StudentPortal/{controller}/{action}/{id}",
defaults: new RouteValueDictionary(new { action = "Index", id = UrlParameter.Optional }),
routeHandler: new DashedRouteHandler()
);
context.Routes.Add("StudentPortal_default", areaDefaultRoute);
If I only set up the route for the "root Area" this works fine. However, as soon as I add the routing configuration for out StudentPortal area all URLs generated with the "@Html.ActionLink" or equivalent methods will contain "student-portal/" at the beginning even if they are not in the student portal. It seems like the student portal route configuration is overriding the configuration for the "root Area". Any idea why this might be happening?
Note that all the links in this site get properly generated when I use the following routes (ie. when I don't use the LowercaseDashedRouting utility):
I am attempting to use your LowercaseDashedRouting utility to make our URLs more SEO friendly. I am struggling with the configuration of the routes. We have a site that uses Areas, but also has a "root Area" (controllers and views that are not in an Area). We are using ASP.NET MVC 4 with Razor.
Here is how I have set up the "root Area" (/App_Start/RouteConfig.cs):
(Note: I need to specify "namespaces" here because we have Home controllers for each area including the "root area")
Here is how I have set up each of our Areas (this is for our StudentPortal area at /Areas/StudentPortal/StudentPortalAreaRegistration.cs):
If I only set up the route for the "root Area" this works fine. However, as soon as I add the routing configuration for out StudentPortal area all URLs generated with the "@Html.ActionLink" or equivalent methods will contain "student-portal/" at the beginning even if they are not in the student portal. It seems like the student portal route configuration is overriding the configuration for the "root Area". Any idea why this might be happening?
Note that all the links in this site get properly generated when I use the following routes (ie. when I don't use the LowercaseDashedRouting utility):
/App_Start/RouteConfig.cs:
/Areas/StudentPortal/StudentPortalAreaRegistration.cs
Thanks for your help.
The text was updated successfully, but these errors were encountered: