MVC ignores culture settings in web.config
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 |
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 |
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
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 |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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
4411211
4411211
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