Closed jeancroy closed 7 years ago
Sorry, I'm not sure what your asking here.
Early URL Localization is a feature such that mysite.com/en/myroute
is internally redirected as mysite.com/myroute
while setting application language to en. It is provided by i18n iis module.
Default document is a feature such that mysite.com/myfolder
is internally redirected as mysite.com/myfolder/index.html
. It is provided by a iis module, bundled by default.
In order to this to work with asp.net MVC, I must ignore route on the folder.
My report is that i18n internal redirect seems to confuse the default document feature. Namely when i18n is enabled with scheme 1 or 2, an url that point to a folder result in a 500 error instead of silently showing the content of index.html.
There are different way to deal with this. One would be making sure the different iis modules work well together. Another would be to remove i18n out of the loop on some requests.
I think the second option (exclusion) is the easiest of those options. There are some positive results, because selecting the VOID scheme, I can have both default document feature and translation working.
So, in the end, the easiest solution I see is an exclusion setting that selectively behave as if the void scheme was chosen. I see one setting to ignore path. UrlsToExcludeFromProcessing
However that setting doesn't save me from the 500 error, my theory is that it happens to late in the pipeline, acting at the OnReleaseRequestState
event.
If I want to conditionally trigger void scheme, the proper place to act would probably be OnBeginRequest
Are you sure i18n.UrlLocalizer.QuickUrlExclusionFilter
doesn't help? Or i18n.UrlLocalizer.IncomingUrlFilters/OutgoingFilters
(although that is a different means to achieve the same thing). Are you sure the URL is being excluded/blacklisted correctly?
https://github.com/turquoiseowl/i18n#exclude-urls-from-being-localized
Those filters are employed early on in the pipeline (in the OnBeginRequest event).
Correction:
i18n.UrlLocalizer.QuickUrlExclusionFilter
and 18n.UrlLocalizer.IncomingUrlFilters
are employed early on in the pipeline (during the OnBeginRequest event).
i18n.UrlLocalizer.QuickUrlExclusionFilter
and 18n.UrlLocalizer.OutgoingUrlFilters
are employed late on in the pipeline (during the OnReleaseRequestState event).
I've setup a new project to reproduce this, and it seems to work ok in the toy project. I'll investiguate more. Closing this for now, thanks.
Part of my site use a static generator, including folder with default
index.html
So for example
mysite.com/help/
point tomysite.com/help/index.html
mysite.com/help/mytopic/
point tomysite.com/help/mytopic/index.html
This is done in MVC with an
routes.IgnoreRoute("help/*");
From what I understand this
index.html
feature is provided by the DefautlDocumentModule, possibly passing by the StaticFile Handler. And i18n break this.i18n.UrlLocalizer.UrlLocalizationScheme = i18n.UrlLocalizationScheme.Void;
Also solve this for me.i18n.UrlLocalizer.QuickUrlExclusionFilter
ori18n.LocalizedApplication.Current.UrlsToExcludeFromProcessing
, do not solve the problem.A related but different problems is Url rewriting rules. Namely I redirect
mysite.com/help/mytopic/how-do-i-xyz
tomysite.com/help/mytopic/how-do-i-xyz.html
. This second problem is solved in the same way as the first. And I have verified that disabling this feature does not make the defaultdocument works.So basically I think UrlRewriting silently redirect, DefaultDocument silently redirect and UrlRewriting can be setup to silently redirect.
I'm not sure the proper way to make all those work, but i can be happy with simply excluding that path since we'll do whole document translation including URL. Then my next problem is that URL exclusion don't work for me.
My guess for the moment would be to have a URL exclusion at the start of the request that conditionally behave like void scheme. Somewhere like here