MVC ignores culture settings in web.config
up vote
-1
down vote
favorite
I'm constructing a MVC website in C# for use in Denmark, and I have therefore set the folloving in my web.config files, in the system.web.globalization node:
culture="da-DK" uiCulture="da-DK"
When I try to enter the date November 21th. 2018 as 21-11-2018 in a "Html.EditorFor(model => model.Date ..." control where model.Date is a DateTime, I get an error saying: "The field Date must be a date."
If I enter 11/21/2018 it gets accepted as if the culture was "en-US", but as the site is intended for use in Denmark, the dates must reflect that.
I hav found plenty of posts across the internet with the same problem, but non with an answer that solved my problem - 90% says: "Set culture in web.config", but I've done it and it do not work.
What an I missing in order for this to work?
c# asp.net-mvc culture
add a comment |
up vote
-1
down vote
favorite
I'm constructing a MVC website in C# for use in Denmark, and I have therefore set the folloving in my web.config files, in the system.web.globalization node:
culture="da-DK" uiCulture="da-DK"
When I try to enter the date November 21th. 2018 as 21-11-2018 in a "Html.EditorFor(model => model.Date ..." control where model.Date is a DateTime, I get an error saying: "The field Date must be a date."
If I enter 11/21/2018 it gets accepted as if the culture was "en-US", but as the site is intended for use in Denmark, the dates must reflect that.
I hav found plenty of posts across the internet with the same problem, but non with an answer that solved my problem - 90% says: "Set culture in web.config", but I've done it and it do not work.
What an I missing in order for this to work?
c# asp.net-mvc culture
You are getting a client side error (becausejquery.validate.js
validates dates based onMM/dd/yyyy
format), not a server side error. You need to reconfigure the$.validator
- refer Date of Birth validation keeps showing
– user3559349
Nov 11 at 21:18
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm constructing a MVC website in C# for use in Denmark, and I have therefore set the folloving in my web.config files, in the system.web.globalization node:
culture="da-DK" uiCulture="da-DK"
When I try to enter the date November 21th. 2018 as 21-11-2018 in a "Html.EditorFor(model => model.Date ..." control where model.Date is a DateTime, I get an error saying: "The field Date must be a date."
If I enter 11/21/2018 it gets accepted as if the culture was "en-US", but as the site is intended for use in Denmark, the dates must reflect that.
I hav found plenty of posts across the internet with the same problem, but non with an answer that solved my problem - 90% says: "Set culture in web.config", but I've done it and it do not work.
What an I missing in order for this to work?
c# asp.net-mvc culture
I'm constructing a MVC website in C# for use in Denmark, and I have therefore set the folloving in my web.config files, in the system.web.globalization node:
culture="da-DK" uiCulture="da-DK"
When I try to enter the date November 21th. 2018 as 21-11-2018 in a "Html.EditorFor(model => model.Date ..." control where model.Date is a DateTime, I get an error saying: "The field Date must be a date."
If I enter 11/21/2018 it gets accepted as if the culture was "en-US", but as the site is intended for use in Denmark, the dates must reflect that.
I hav found plenty of posts across the internet with the same problem, but non with an answer that solved my problem - 90% says: "Set culture in web.config", but I've done it and it do not work.
What an I missing in order for this to work?
c# asp.net-mvc culture
c# asp.net-mvc culture
edited Nov 11 at 21:12
user3559349
asked Nov 11 at 16:44
Morny
213
213
You are getting a client side error (becausejquery.validate.js
validates dates based onMM/dd/yyyy
format), not a server side error. You need to reconfigure the$.validator
- refer Date of Birth validation keeps showing
– user3559349
Nov 11 at 21:18
add a comment |
You are getting a client side error (becausejquery.validate.js
validates dates based onMM/dd/yyyy
format), not a server side error. You need to reconfigure the$.validator
- refer Date of Birth validation keeps showing
– user3559349
Nov 11 at 21:18
You are getting a client side error (because
jquery.validate.js
validates dates based on MM/dd/yyyy
format), not a server side error. You need to reconfigure the $.validator
- refer Date of Birth validation keeps showing– user3559349
Nov 11 at 21:18
You are getting a client side error (because
jquery.validate.js
validates dates based on MM/dd/yyyy
format), not a server side error. You need to reconfigure the $.validator
- refer Date of Birth validation keeps showing– user3559349
Nov 11 at 21:18
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
One of possible reasons is as follows: you send GET (not POST) requests to web server.
Your custom culture will be used only for processing of POST requests. For GET requests invariant culture is always being used.
But I would recommend you to post minimal working example here.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
One of possible reasons is as follows: you send GET (not POST) requests to web server.
Your custom culture will be used only for processing of POST requests. For GET requests invariant culture is always being used.
But I would recommend you to post minimal working example here.
add a comment |
up vote
0
down vote
One of possible reasons is as follows: you send GET (not POST) requests to web server.
Your custom culture will be used only for processing of POST requests. For GET requests invariant culture is always being used.
But I would recommend you to post minimal working example here.
add a comment |
up vote
0
down vote
up vote
0
down vote
One of possible reasons is as follows: you send GET (not POST) requests to web server.
Your custom culture will be used only for processing of POST requests. For GET requests invariant culture is always being used.
But I would recommend you to post minimal working example here.
One of possible reasons is as follows: you send GET (not POST) requests to web server.
Your custom culture will be used only for processing of POST requests. For GET requests invariant culture is always being used.
But I would recommend you to post minimal working example here.
answered Nov 11 at 17:27
Serega
435211
435211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250921%2fmvc-ignores-culture-settings-in-web-config%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are getting a client side error (because
jquery.validate.js
validates dates based onMM/dd/yyyy
format), not a server side error. You need to reconfigure the$.validator
- refer Date of Birth validation keeps showing– user3559349
Nov 11 at 21:18