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?










share|improve this question
























  • 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

















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?










share|improve this question
























  • 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















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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 21:12







user3559349

















asked Nov 11 at 16:44









Morny

213




213












  • 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


















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














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.






share|improve this answer





















    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',
    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
    });


    }
    });














    draft saved

    draft discarded


















    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








    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 17:27









        Serega

        435211




        435211






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation