跨浏览器/服务器的日期格式不一致

时间:2015-09-25 22:06:58

标签: asp.net asp.net-mvc google-chrome

所以我目前在我的ASP.net MVC5应用程序中有一个奇怪的日期格式问题。我已应用以下设置:

的Web.config

<globalization culture="nl-BE" uiCulture="nl-BE" />

数据模型

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DueDate { get; set; }

甚至在我的控制器中我也尝试过手动设置文化和UICulture。

当我在本地计算机(Win 10,ENG / US配置)上调试它时,它会按预期显示日期。还有像Edge或Firefox一样的Chrome。

但是,当我将此站点发布到我的服务器时(Win 10 pro,带有nl-BE键盘布局的英语)。然后从此服务器(localhost)浏览到此站点。 IE和Firefox以正确的格式显示日期选择器。但是Chrome默认为mm / dd / yyyy。我尝试过修改我能想到的每一个设置,但是我无法获得chrome以正确的格式显示日期。有人有任何想法吗?

作为参考,来自服务器的标头与我的开发机器上的标头:

开发机器

Response headers
Cache-Control:private, s-maxage=0
Content-Encoding:gzip
Content-Length:3470
Content-Type:text/html; charset=utf-8
Date:Fri, 25 Sep 2015 22:03:35 GMT
Server:Microsoft-IIS/10.0
Vary:Accept-Encoding
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Frame-Options:SAMEORIGIN
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcVXNlcnNcR2xlbm5cRG9jdW1lbnRzXEJhZXJ0XEJhZXJ0TVZDNQ==?=

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Cookie:__RequestVerificationToken=gRwm97zFECc_tLmXiIZGLn1g3gZo36Gk_zT6ufrkC00FlKkszN0gsVT7nt6z4KTu9_EiXTHo4qL27GDLmIHCpo-awOP39KyI9PU5eI5JkQU1; .AspNet.ApplicationCookie=SvY0ygIeVi2w8Y2K4TeLgFBbx0VXKi0YaVC7vsEG2iRq9vqt_rPySPNYH9YxZcd0sLFFld1Ue6pdfElWB44yfM4wGSUUkuCJckntXy8JhIYfgOSRyeBBi_DzLykA_Jjypjr3Wd6GsSZbhQ6SnMpGqhKwJlC-6jZCaszmWf4jCoXr5JsQWL-A-XyNcNl5au4PwqQR0PtcHaHi1b-xhEzWECBDYg7MxsCpA_3ogUowON9ftn5fXUFI1VuTCgCHuhytWOeDczPUnATZjcD1Qg1oxwFfZRD9faFarqLGj3lJ1XxvkudSW8mL_aBwcEznPcTUgEt6QYpMVvuQfbxNPpdFnOUIs7epuxo6EmGOf7tIy9iRyMSMXeJA15i_G6CkyhsWaZOjHl-T1rTHCIpsqJ7_iJK-ZpPvcVEU_c3VnyCJdHTc7dOj-mRlMiuW7Ng4Qd7trRZGecv3-aGrAMdGGKW9uShhOm6Y4LbAIhjItRQ4dZQ1QU4tK4JK4KCI2axh6dm37Tzyu-DPVzG9W_BZox5fZw
Host:localhost:58980
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36

服务器机器

Response headers
Cache-Control:private, s-maxage=0
Content-Length:13449
Content-Type:text/html; charset=utf-8
Date:Fri, 25 Sep 2015 22:05:49 GMT
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Frame-Options:SAMEORIGIN
X-Powered-By:ASP.NET


Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:nl,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:__RequestVerificationToken=n-pWZRH9H-43UCQr45yiz7VoWt_yAN5HNmH_QgfPVhWio1j3qs5M7ytBgJPyJCLMQeSB-ijuC0FK_51MwOEXYvPZ-Wv-MpWCQWSRb0AUOMc1; .AspNet.ApplicationCookie=Te7ClXd741mhPk4hrU0YG-CFiOnnLVcbjN7so8m0JT6R-vBQKhCFQ2vSScqsyIb0Q7gYL10Q2zpB3OA492y8dtu20PT7wvbelYYo3iVWlpMPAHfV-3dG7KTpb1W4jMT0-3o0OVXz6Dt_MZLT8yaxmykbNYl5rmIERkHH5dWiw-J-IDlpi3zzmWFT8a7SqiC661poDiQUqhNePaSKAEPQ_zY1lwJ0-_6cEK8HwgitA-61ez1rHp_PP0XjjVY0h9l29MivAqu77bWgj9pZDcPAqd9M2Iaez5sW6_qzo5aRhsEEZZvS2zjOF-8SpG0-4uZnrqma3VpU3_upj5PawLlwzoJsXeI89v9Lafd-9V5TegTMr0n6A0Zjyd7Zrz-tYrgqZfxekEIVh7odrAZkfbjDaQE1NU9UCFUYsX5N8ObD5YbEI0_pzkRIK-hvBmGEKCdS3xE6l79LCUOc8G4m0RrmI9BukKg1E6iMjX8w-LoxOPMqLCW4yPtH-bhpwqn91nMz
Host:localhost
Referer:http://localhost/Invoices/Details/ba143e9b-fabc-44c6-abe1-a51e00b0a8bb
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

编辑:我已经看过其他问题了,没有一个能解释为什么它可以在机器A上运行而且不会在机器B上运行......

0 个答案:

没有答案