4

We enabled localization for one of the publications and we can see all the Tridion pages in our website. But when we try to access any custom controllers or DXA controllers, we get 404 error.

The entries in Global.asax for enabling the Controllers are in this format:

routes.MapRoute(
   "Core_Admin",
   "admin/{action}",
   new { controller = "Admin", action = "Refresh" }
);
routes.MapRoute(
   "Core_Admin_Loc",
   "{localization}/admin/{action}",
   new { controller = "Admin", action = "Refresh" }
);

Please note that this code works for a site which has no localization set. So it seems to be an issue in the {localization} field of the route mapping.

The localization information set in Topology manager is:

CmEnvironmentId     : Tridion_cm_*****
PublicationId       : tcm:0-91-1
EnvironmentPurpose  : Staging
WebApplicationId    : ****Website_RootWebApp
RelativeUrl         : /
PrimaryMappedUrl    : http://dev.*****.com/en/us/
IsOffline           : False
CdEnvironment       : 
Id                  : ****WebsiteMappingENUS
ExtensionProperties : {} 


ContextUrl           : /en/us
WebsiteId            : ***Website
EnvironmentPurpose   : Staging
CdEnvironment        : 
ScopedRepositoryKeys : {}
Id                   : ****Website_RootWebApp
ExtensionProperties  : {}


BaseUrls             : {http://dev.****.com, http://localhost:***}
CdEnvironmentId      : CdEnvironment1
EnvironmentPurpose   : Staging
CdEnvironment        : 
ScopedRepositoryKeys : {}
Id                   : ****Website

In Global.asax, if we replace the text {localization} with en/us/, the controller works.

Any help is appreciated.

Edit 1:

Updated the site localization information in Topology Manager to:

CmEnvironmentId     : Tridion_cm_******
PublicationId       : tcm:0-91-1
EnvironmentPurpose  : Staging
WebApplicationId    : ****Website_RootWebApp
RelativeUrl         : /en/us
PrimaryMappedUrl    : http://dev.****.com/en/us
IsOffline           : False
CdEnvironment       : 
Id                  : ****WebsiteMappingENUS
ExtensionProperties : {}



ContextUrl           : /
WebsiteId            : ***Website
EnvironmentPurpose   : Staging
CdEnvironment        : 
ScopedRepositoryKeys : {}
Id                   : ****Website_RootWebApp
ExtensionProperties  : {}

Still getting the same error.

2
  • What happens if you change the route URL pattern to {loc1}/{loc2}/whatever? Maybe ASP.NET MVC doesn’t like a URL path variable with a slash in it. Dec 19, 2018 at 17:21
  • You were absolutely right! MVC treats "/" as URL part seperator and will not allow to be a part of {localization}. Also, the localization path starts with a "/" and MVC routes will not support it. I broke the route mapping as per your suggestion and added URL Routing constraints for the Custom Controller URLs only. Please add the comment in your answer and I will accept it as a solution to my question. Dec 24, 2018 at 6:32

2 Answers 2

2

ASP.NET does not allow URL path variables to contain a slash character (the path segment separator).

So, if you expect your localization to have multiple URL path segments, you have to define a route with multiple URL path variables. For example, {loc1}/{loc2}/whatever.

1
  • MVC treats "/" as URL part separator and will not allow to be a part of {localization}. Also, the localization path starts with a "/" and MVC routes will not support it. I broke the route mapping as per your suggestion and added URL Routing constraints for the Custom Controller URLs only. The new mapping then works for me. Dec 26, 2018 at 1:27
1

There is something fishy with your Topology Manager configuration: your ***Website_RootWebApp has a Context URL of /en/us. Note the contradiction: a root Web App has a Context URL / per definition.

Your DXA Web App is most likely indeed installed on website root level, so the Context URL in Topology Manager should be changed to reflect reality. The /en/us URL path should be the Relative URL of the appropriate Mapping in Topology Manager.

1
  • Thanks Rick for looking it. I updated the Topology Manager and have updated the information above. I am still getting the same error. Dec 19, 2018 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.