I'm running Tridion 9.6, DXA 2.2.9 .net and the GraphQL providers to CD Services. Topology Manager is installed and configured for both hostnames and contexts.
I have a Publication identified by hostname and context (/en
). I do not have a Publication mapped to the root context (/
).
DXA works fine for requests to the hostname/en
URLs. However, I can't seem to serve any static files that are in the root of the website (e.g. /js/main.js
). These are all static files on the filesystem. Instead, I get error Sdl.Web.Common.DxaUnknownLocalizationException: No matching Localization found for URL
coming from the StaticContentModule
:
Sdl.Web.Mvc.Configuration.WebRequestContext.get_Localization() in C:\DXAGitHub\dxa-suite\repositories\dxa-web-application-dotnet\Sdl.Web.Mvc\Configuration\WebRequestContext.cs:28
Sdl.Web.Mvc.Statics.StaticContentModule.OnPreRequestHandlerExecute(Object sender, EventArgs eventArgs) in C:\DXAGitHub\dxa-suite\repositories\dxa-web-application-dotnet\Sdl.Web.Mvc\Statics\StaticContentModule.cs:121
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94
Looking at the source code (https://github.com/RWS/dxa-web-application-dotnet/blob/5c24bcc990f53a7357362b94e2526fd05a3f710b/Sdl.Web.Mvc/Statics/StaticContentModule.cs#L123), I see it needs a Localization object.
There is no Publication that maps to the root of the website, therefore there is no Localization available.
How can one server static content in this case?
Notes:
- Adding a Publication for context / is not feasible.
- I implemented an
IUnknownLocalizationHandler
, but that is only used here in the StaticContentModule (link: https://github.com/RWS/dxa-web-application-dotnet/blob/5c24bcc990f53a7357362b94e2526fd05a3f710b/Sdl.Web.Mvc/Statics/StaticContentModule.cs#L62), so it doesn't help. - I tried excluding the path from routes
routes.IgnoreRoute("js/{*pathInfo}")
, but still the HttpModule is called.
How can I prevent some URL patterns be handled by the StaticContentModule
?
So far, all I can see is modify the open source StaticContentModule
to allow it requests when there is no Localization
object.
Looking forward to your thoughts and thanks in advance!