小编Bab*_*bak的帖子

控制台应用程序中的 IStringLocalizer

拥有一个包含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库?该控制台应用程序根据用户选择的语言生成内容并通过电子邮件发送。

localization console-application .net-core

5
推荐指数
1
解决办法
1647
查看次数

SharpSVN中工作目录的当前版本

  1. 如何获取工作目录的当前版本?

  2. 如何从存储库的服务器获取文件的特定修订版?

c# svn sharpsvn

3
推荐指数
1
解决办法
1751
查看次数

SharpSVN和修订版中的新/修改文件

如何获取已在特定修订中添加或修改的所有文件(仅限路径/名称)的列表?

c# sharpsvn

3
推荐指数
1
解决办法
1715
查看次数

.Net Core behind NGINX returns 502 Bad Gateway after authentication by IdentityServer4

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)

nginx .net-core kestrel-http-server identityserver4

2
推荐指数
2
解决办法
3837
查看次数

Ok() 与 Ok(null)

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)

asp.net-mvc asp.net-core asp.net-core-webapi

2
推荐指数
1
解决办法
4558
查看次数

JavaScript性能,同时生成太多元素

哪一个更快,为什么?

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)

有更有效的方法吗?

javascript performance

1
推荐指数
1
解决办法
123
查看次数