DateTime.TryParse在Azure Web App中失败 [英] DateTime.TryParse failing in Azure Web App

查看:70
本文介绍了DateTime.TryParse在Azure Web App中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发计算机的文化是en-NZ,我的时区设置为新西兰时间(UTC + 12:00)。在美国西部的服务器上,DateTime.TryParse出现故障。

My development machine's culture is en-NZ and my timezone is set to New Zealand time (UTC+12:00). A DateTime.TryParse is failing on the server, which is in West US.


  1. 如何检查和更改区域性和时间服务器上我的Web应用程序上的设置?

  1. How can I check and change culture and time settings on my web app on the server?

我可以在服务器上交互运行Powershell或C#代码并查看输出,只是为了测试内容,例如说

Can I run Powershell or C# code on the server interactively and see output, just to test stuff, like say

Console.WriteLine(CultureInfo.CurrentCulture.ToString());


如果您认为我有其他想法,也欢迎

Any other thoughts are welcome if you think I'm approaching this the wrong way.

推荐答案

我只是用Kudu来回答这个问题。 Kudu很棒。

I just used Kudu to answer this. Kudu is amazing.

我只是认为 Kudu是Azure网站中git部署的引擎。它也可以在Azure外部运行。

I just thought that "Kudu is the engine behind git deployments in Azure Web Sites. It can also run outside of Azure."

但是请转到 https:// [mysite] .scm.azurewebsites .net / 。这实际上是Kudu的Web界面,它告诉您有关环境的所有信息。您甚至可以运行powershell和cmd。

But go to https://[mysite].scm.azurewebsites.net/. This is actually a web interface for Kudu and tells you everything you want to know about the environment. You can even run powershell and cmd. Check it out.

通过将其放在web.config中解决此问题:

Fixed the problem by putting this in the web.config:

<configuration>
    <system.web>
        <globalization culture="en-NZ" uiCulture="en-NZ"  />
    </system.web>
</configuration>

顺便说一句,使用PowerShell,服务器上的文化是美国(美国西部数据中心) 。时间是UTC。我不需要更改时间,但是这是操作方法:

By the way, using powershell, the culture on the server was en-US (West US datacentre). The time was UTC. I didn't need to change the time, but here is how to do that:

https://blogs.msdn.microsoft.com/tomholl/2015/04 / 06 /更改 azure-web-apps上的服务器时间区域 /

基本上,您所需要做的就是添加一个名为WEBSITE_TIME_ZONE的应用程序设置(通过门户或管理API),并将其设置为时区名称为在Windows注册表中的HKLM\软件\Microsoft\Windows Nt\CurrentVersion\Time Zones(例如 AUS东部标准时间)中定义。

Basically, "All you need to do is add an Application Setting (via the portal or the management APIs) called WEBSITE_TIME_ZONE and set that to the name of the time zone as defined in the Windows Registry under HKLM\Software\Microsoft\Windows Nt\CurrentVersion\Time Zones\ (for example, "AUS Eastern Standard Time")."

这篇关于DateTime.TryParse在Azure Web App中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆