试图强制执行英国约会文化 - webapi [英] Trying to enforce UK date culture - webapi
问题描述
与ASPNET Core Web Api有一个奇怪的问题。
我在startup.cs中设置了全球化我已经设定了文化(我相信!) 。
Having a strange Issue with ASPNET Core Web Api.
I have setup the globalisation in the startup.cs I have set the cultures (well I believe!).
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.Configure<RequestLocalizationOptions>(Options =>
{
Options.DefaultRequestCulture = new <pre> Microsoft.AspNetCore.Localization.RequestCulture("en-GB");
Options.SupportedCultures = new List<CultureInfo> { new CultureInfo("en-GB") };
}
//All other configuration options
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if(env.IsDevelopment())
{
//Set Dev Env
}
else
{
//Set Live Env
}
app.UseRequestLocalization();
app.UseMVc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
}
}
}
现在,如果我使用Visual Studio进行本地测试,它将只接受英国日期格式,这是必需的。但如果我部署到我们的测试环境,它只会接受美国日期格式,这是我想删除的东西。
任何人都可以指出我正确的方向,因为我觉得我已经尝试了所有明显的对我来说!
我还确保部署的网络服务器将英国作为其所在地和地区等。
谢谢
Simon
我尝试过:
所有上述内容都是我得到的。
Now if I test locally using Visual Studio it will only accept UK Dateformats which is what is required. But if I deploy to our test environment, it will only accept US Dateformats which is something that I am trying to remove.
Can anyone point me in the right direction as I feel I have tried all of the obvious to me!
I have also ensured that the webserver being deployed to has United Kingdom as its locations and region etc.
Thanks
Simon
What I have tried:
All of the above is where I got it too.
推荐答案
请不要回答,忘记检查我的部署是否成功运行但是失败了!!
使用邮递员重新部署和验证API,它有效!
Please don't answer, forgot to check my deployment worked successfully and it failed!!
Redeployed and verfied the API using postman and it works!
这篇关于试图强制执行英国约会文化 - webapi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!