拥有一个包含resx文件的库,并在 ASP.NET Core 中使用本文档全球化和本地化,并在 Startup.cs 中添加以下代码,我们本地化了我们的 Web 应用程序:
services.AddMvc()
.AddDataAnnotationsLocalization(option =>
{
option.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof({the-resx-library}));
})
.AddViewLocalization()
Run Code Online (Sandbox Code Playgroud)
在控制器中:
private readonly IStringLocalizer<{the-resx-library}> _localizer;
public AccountController(IStringLocalizer<{the-resx-library}> localizer)
{
_localizer = localizer;
}
[HttpGet]
public IActionResult Index()
{
string text = this._localizer["Hello"];
return View();
}
Run Code Online (Sandbox Code Playgroud)
问题是我们如何在控制台应用程序中使用resx库?该控制台应用程序根据用户选择的语言生成内容并通过电子邮件发送。
Having to applications auth and store and authenticating using IdentityServer4 and both are behind NGINX.
The store application successfully authenticates but after coming back from the auth application we get 502 Bad Gateway from NGINX.
Any idea what is going wrong here?
Auth app log:
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 117.7292ms 200 text/html; charset=UTF-8
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.0 POST http://auth.example.com/connect/token application/x-www-form-urlencoded 279
info: IdentityServer4.Hosting.IdentityServerMiddleware[0]
Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
info: IdentityServer4.Validation.TokenRequestValidator[0]
Token request validation success
{
"ClientId": "ExampleStore", …Run Code Online (Sandbox Code Playgroud) Ok()vs 和有什么区别Ok(null)?
返回Ok(null)状态代码204,没有正文,只有标头,因此我们必须以这种方式更改代码:
[HttpGet]
public IActionResult GetTest(string test)
{
MyClass result = GetMyClass(test)
if(result == null) return Ok();
return Ok(result);
}
Run Code Online (Sandbox Code Playgroud) 哪一个更快,为什么?
1.
for(var i=0; i<1000; i++)
document.getElementById('parent').innerHTML +=
'<input id="id_'+i+'" type="checkbox" value="'+i+'" /><label for="id_'+i+'">'+i+'</label>';
Run Code Online (Sandbox Code Playgroud)
2.
for(var i=0; i<1000; i++){
var cb = document.createElement('input');
cb.type = 'checkbox';
cb.id = 'id_'+i;
cb.value = i;
var l = document.createElement('label');
l.htmlFor = 'id_'+i;
l.appendChild(document.createTextNode(i.toString()));
parentElement.appendChild(cb);
parentElement.appendChild(l);
}
Run Code Online (Sandbox Code Playgroud)
有更有效的方法吗?
.net-core ×2
c# ×2
sharpsvn ×2
asp.net-core ×1
asp.net-mvc ×1
javascript ×1
localization ×1
nginx ×1
performance ×1
svn ×1