turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Too many redirects using i18n.UrlLocalizationScheme.Scheme2 (ERR_TOO_MANY_REDIRECTS) #233

Open rafaeldruiz opened 8 years ago

rafaeldruiz commented 8 years ago

The default language is "en" (default of i18n).

Using i18n.UrlLocalizationScheme.Scheme1 (default of i18n) everything works fine. All languages not configured are redirected to "localhost/en":

Using i18n.UrlLocalizationScheme.Scheme2 to hide the default schema, the browser shows the error "Too many redirects" (ERR_TOO_MANY_REDIRECTS) with the same scenarios.

What can be done to fix this issue?

Thanks, Rafael.

turquoiseowl commented 8 years ago

With Scheme2, is "localhost/en" being redirected to "localhost/" ?

What versions of i18n and ASP.NET are you using?

rafaeldruiz commented 8 years ago

Schema1:

Schema2:

Versions:

turquoiseowl commented 8 years ago

I'm presuming that is ASP.NET 4.5 under MVC? That should work fine. I just want to rule out a new version of ASP.NET causing a problem.

Have you tried clearing browser cache between change of schemes (Ctrl-F5)? And different browsers?

Can you provide the http responses for, say, "localhost/en-US" (Scheme2).

This is quite a common problem I've had when setting up a site. In debug builds there should be Debug trace output to help diagnose the redirects. If you fancy building and referencing the source, the EarlyUrlLocalizer.ProcessIncoming method is a good starting point with redirects.

rafaeldruiz commented 8 years ago

Yes, it's ASP.NET 4.5.

All browsers have the same result:

captura de tela 2015-11-05 as 11 41 49

turquoiseowl commented 8 years ago

Please provide the initial http GET request including headers, the initial GET response including headers, then the same for the next request/response i.e. the one that loops.

rafaeldruiz commented 8 years ago

Remote Address:[::1]:2699 Request URL:http://localhost:2699/en-us/sites/10001 Request Method:GET Status Code:302 Moved Temporarily Response Headers view source Content-Length:0 Date:Thu, 05 Nov 2015 17:02:23 GMT Location:/en-us/sites/10001 Server:Microsoft-IIS/8.0 X-Powered-By:ASP.NET X-SourceFiles:=?UTF-8?B?WTpcRG9jdW1lbnRzXE15UHJvamVjdHNcTGVhZEdyaWRcc291cmNlXFVJXFVJVXNlclxlbi11c1xzaXRlc1wxMDAwMQ==?= Request Headers view source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Cookie:_hjUserId=7fedb156-fbc6-4f42-ac1b-dcc2314bc1c8; current-lang=en-US; ASP.NET_SessionId=vxx0wur3rhdxe2qryzvh5o2j; __RequestVerificationToken=KqAevXKp4glW_AyMue6xwJTAHDE2DTBKngSdzH79XNP-NXBBblGoygcMnPBgV8BuUlNwjnI_kfwGZ_Bn8lEJn8Lg2GO8nePuQoLDlP2x2vM1; .AspNet.ApplicationCookie=cP7Yxf5Ik66DL7q2XFK9djM1AUSfZ39RREdRY0-Qw4aO9Nawpq0UdBg9xZGJJEx0ksCEHpOY7bjXgcKGrY88UBw6xuUgwRds86-VAOxH0FlFNUzvd6EhQtfZHmtY1KiJrnp99Tqqbyx0ik6EsUpozNkHz_VpK-8GJpcqJLixnW2Nbg9O0AjkLiV-OXz1Zn2GGu8xhY41PWBJTlNpJt-iIvW-GZcwsMwq9xUho3w9cq-aMwd_rKj6X4kgb0NN6Ika8wL8IP_nEfHpWMWeBSMGjdjQgw-QUXi_25oVgTe1KCj2aEMM7czii7nL8PLxnxcRi-USFNHdwK5cmRRNgyl_kE38NjBGgMaRPXivdf2zlJNNcFxs4MK83JI-tBqLChUjXMc83l-6xkg8AJL1R9_H_dilBb7EK6n3fVQyhiBm_yUPGfQsOFq-3QgeiXCpaA-9e8t6vyl1iCoJDkQqgwM2cW885hAv9wnlP54MxxL-mn--hGyv_nHQHULH8ytQo07N Host:localhost:2699 Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

turquoiseowl commented 8 years ago

I've pushed what is hopefully a fix for this. It would help me a lot if you would test with a clone of this repo before I submit a new NuGet package. Thanks.

turquoiseowl commented 8 years ago

Note to self: A potential gotcha when swapping between Scheme1 and 2 during dev is that browsers can remember permanent redirects, so it is a good idea to flush this at times. In FireFox this is done by right-clicking the site in the History window and selecting "Forget about this site". Just clearing the browser cache is not enough, in FF at least.

rafaeldruiz commented 8 years ago

The redirect loop is fixed, but "localhost/en" is not redirecting to "localhost/".

Are you going to fix the redirect of "localhost/en"?

turquoiseowl commented 8 years ago

Yes, that sounds right for Scheme2.

There is a placeholder in the code called Scheme3 for /en -> / which is there for when someone wants to code it. https://github.com/turquoiseowl/i18n/issues/216

rafaeldruiz commented 8 years ago

Are you going to fix the redirect of "localhost/en" for Scheme2 before the submit of a new Nuget package?

rafaeldruiz commented 8 years ago

Any news about the fix of "localhost/en" and the new version of the nuget package?

turquoiseowl commented 8 years ago

The latest build is now on nuget: v2.1.5.

Scheme2 should now works as documented. The 'fix' you refer to would be Scheme3 which is awaiting implementation. I'm not sure at present when I'll have time to do that.