-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GET Api calls are re-directed #215
Comments
Please see https://github.com/turquoiseowl/i18n#exclude-urls-from-being-localized. Thank you. |
Here is how you can exclude APIs from localization:
|
update: when I use:
instead of:
things to works as expected. Hi Martin thanks for your response. Still have the trouble, and hope you could give me a few pointers. I just forked v2.1.4.0, build it, updated dll's in asp.net mvc project (tested it works), read the documentation and added your code suggestion (i18n.UrlLocalizer.OutgoingUrlFilters). However, I'm still getting the re-direct behaviour. If I comment out the following in web.config the GET api method runs correctly:
In
The code ( Api methods:
Fiddler GET call (the one failing):
Fiddler response to GET call:
Fiddler POST call (works):
Fiddler response to POST call:
the i18n web.config -> appSettings keys:
|
Hmm, I can't see anything that you're doing wrong. If I set a breakpoint in my OutgoingUrlFilter delegate then debug a request, here's my call stack when the BP get's hit:
If you can try setting breakpoints back along that chain you might be able to see where it goes wrong. |
Ah yes, sorry, I also have a matching IncomingUrlFilters delegate:
|
Thanks. As mentioned, when I use:
my Api GET calls (http://domain/api/xxx) works just fine. |
I'm adding web api 2 methods to a asp.net mvc 5 project, however, when i18n is enabled, my GET method calls are being redirected to selected country. For example: http://xxx/api/v1/system/getappversion2 is redirected to http://xxx/en/v1/system/getappversion2
My POST methods are called correctly with or without i18n.
Must I somewhere exclude api from the i18n logic?
Two examples:
[Route("api/v1/system/getappversion"), HttpPost]
public HttpResponseMessage GetAppVersion()
{
const int appVersion = 1;
return Request.CreateResponse(HttpStatusCode.OK, new
{
AppVersion = appVersion
});
}
[Route("api/v1/system/getappversion2"), HttpGet]
public HttpResponseMessage GetAppVersion2()
{
const int appVersion = 1;
return Request.CreateResponse(HttpStatusCode.OK, new
{
AppVersion = appVersion
});
}
GetAppVersion (POST) work with or without i18n.
GetAppVersion2 (GET) only works without i18n. When i18n api/v1/system/getappversion2 is re-directed to en/v1/system/getappversion2
In Fiddler I get:
Terse summary
GET http://localhost:50708/api/v1/system/getappversion2
302 Redirect to /en/v1/system/getappversion2
GET http://localhost:50708/en/v1/system/getappversion2
404 Not Found (text/html)
Full summary
Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 302 HTTP localhost:50708 /api/v1/system/getappversion2 0 fiddler:9088
2 404 HTTP localhost:50708 /en/v1/system/getappversion2 3.204 private text/html; charset=utf-8 fiddler:9088
Headers only
GET http://localhost:50708/api/v1/system/getappversion2 HTTP/1.1
User-Agent: Fiddler
Host: localhost:50708
HTTP/1.1 302 Moved Temporarily
Location: /en/v1/system/getappversion2
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcTW9ydGVuXFByb2plY3RzXE5TQVxJblN0b3JlRXhjZWxsZW5jZVxzcmNcSW5TdG9yZUV4Y2VsbGVuY2UuV2ViXGFwaVx2MVxzeXN0ZW1cZ2V0YXBwdmVyc2lvbjI=?=
X-Powered-By: ASP.NET
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval' https://.googleapis.com https://.gstatic.com https://www.google-analytics.com https://*.google.com; frame-ancestors 'self' https://www.google.com
Date: Wed, 08 Jul 2015 19:40:56 GMT
Content-Length: 0
GET http://localhost:50708/en/v1/system/getappversion2 HTTP/1.1
User-Agent: Fiddler
Host: localhost:50708
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcTW9ydGVuXFByb2plY3RzXE5TQVxJblN0b3JlRXhjZWxsZW5jZVxzcmNcSW5TdG9yZUV4Y2VsbGVuY2UuV2ViXHYxXHN5c3RlbVxnZXRhcHB2ZXJzaW9uMg==?=
X-Powered-By: ASP.NET
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval' https://.googleapis.com https://.gstatic.com https://www.google-analytics.com https://*.google.com; frame-ancestors 'self' https://www.google.com
Date: Wed, 08 Jul 2015 19:40:56 GMT
Content-Length: 3204
The text was updated successfully, but these errors were encountered: