-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Dynamic C# API Clients may not handle DateTime on QueryString when client and server cultures are different #3339
Comments
hi @NecatiMeral eg
|
hi @maliming, the faulty request contains the following parameters:
The issue is the Volo.Abp.Http.Client.DynamicProxying.UrlBuilder private static void AddQueryStringParameter(StringBuilder urlBuilder, bool isFirstParam, string name, object value)
{
urlBuilder.Append(isFirstParam ? "?" : "&");
// NM@24.03.2020: HACK to make datetime-query parameter work independent from the clients culture
if (value is DateTime dateTime)
{
urlBuilder.Append(name + "=" + System.Net.WebUtility.UrlEncode(dateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")));
}
else
{
urlBuilder.Append(name + "=" + System.Net.WebUtility.UrlEncode(value.ToString()));
}
} Maybe a more standarized format should be used for datetime parameters. I would consider using ISO-8601 format with optional abbreviations (such as my format). |
hi @NecatiMeral |
The server-side implementation expects a invariant-culture input. I think this issue will occur on floating values (0.00 vs 0,00) too. |
@hikalkan Should we change the default behavior of |
I don't think that we have to adjust anything on the I can submit a PR adressing this issue by making my hack (#3339 (comment)) more production ready. |
I agree, and also your solution seems good :) I will check & fix it. Thanks. |
Hi,
I'm encountering a issue when using dynamic c# api clients and having datetime parameters on my service dtos.
When using the swagger-UI, the following, working request is created:
http://localhost:44344/api/app/rosterPlanning?ContractNumber=1003666-01&Begin=2019-12-01%2000%3A00%3A00&End=2019-12-31%2000%3A00%3A00
The
DynamicHttpProxyInterceptor
creates the following request, which doesn't work:http://localhost:44344/api/app/rosterPlanning?ContractNumber=1003666-01&Begin=01.12.2019+00%3A00%3A00&End=31.12.2019+00%3A00%3A00
The underlying issue is that the datetime value get's string encoded using the wrong cultureinfo.
Example code
I think this issue can be fixed in the
Volo.Abp.Http.Client.DynamicProxying.UrlBuilder.AddQueryStringParameter
method.Is there any workaround (such as custom validation) to fix this issue?
The text was updated successfully, but these errors were encountered: