我正在尝试动态更改语言环境以更改i18n语言。我有两个文件,一个具有英语值,另一个具有法国值。
我现在尝试的是这样的:
ngOnInit() {
const localeName = localStorage.getItem('locale') || 'fr';
import(`@angular/common/locales/${localeName}.js`).then(locale => {
registerLocaleData(locale.default);
});
}
Run Code Online (Sandbox Code Playgroud)
但是它给了我以下错误:
error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
Run Code Online (Sandbox Code Playgroud)
关于如何动态地从英语切换到法语的任何想法?:/
目前正在尝试 Rider(用于 .Net 的 JetBrains IDE)。我曾经在 Visual Studio Enterprise 上为 c# asp.net MVC 项目工作,我想知道是否有一种方法(在 Rider 上)可以像“添加 -> 视图 -> 使用创建/删除/更新/列表”一样“Visual Studio 上的功能?
会生成这样的 CRUD 视图的东西:
@model IEnumerable<Web.Models.Warrior>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Health)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Health)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | …Run Code Online (Sandbox Code Playgroud) asp.net-mvc asp.net-mvc-scaffolding rider visual-studio-2017
我们的高级开发人员最近离开了我们,我正试图游进 IdentityServer 的海洋。
有几件事我不明白,也找不到相关信息。例如,当您运行客户端应用程序时,它会被重定向到IdentityServer/Account/Login名为 的参数returnUrl。
这returnUrl似乎用于很多事情,例如使用以下命令检索授权上下文:
await _interaction.GetAuthorizationContextAsync(returnUrl);
Run Code Online (Sandbox Code Playgroud)
我的第一个问题是:
returnUrl 从哪里来?它是如何/在哪里创建的?
第二个问题是:
登录后是否可以将其存储在客户端应用程序中的某个位置?我的意思是,在客户端应用程序中有一个点,我们必须发送邮件来创建新帐户。这些邮件会在 IdentityServer 的“注册”页面中重定向新用户。我想要做的是在此处使用 returnUrl 将新用户重定向到正确的客户端应用程序。
谢谢你的时间 !
编辑 :
这是我的客户端(在 IdentityServer 中)中设置的返回 url:
RedirectUris = {"http://localhost:44349" + "/signin-oidc"}
Run Code Online (Sandbox Code Playgroud)
这是当我启动客户端应用程序时 IdentityServer 中的 Login 方法接收到的 returnUrl
"/connect/authorize/callback?client_id=MyApplication_Web&redirect_uri=http%3A%2F%2Flocalhost%3A44349%2Fsignin-oidc&response_type=code%20id_token&scope=openid%20offline_access%20roles%20Cri_Identity_Serveur_Api.Full_Access&response_mode=form_post&nonce=637230882720491348.YmQzODA4ZTQtNDczZS00OWYwLWFmNmEtYjA2NmQ3YmIwZjg2YzdiODk4ZDYtMTU1YS00ZTM0LWE0MGEtNDVjOWNkZWFiYTM1&state=CfDJ8Ly2XCz96vdGkR4YQuJ4jeE-v9P4l1W7fLWpJcCGZpt1rMpXyWqEGdnaeRZfiZy4M4Z79LcixUbo06zImhsxwbgyV4hK82qmn0mI6wkrxwraT1tH3XNCdSXCfUJqwk_hZguMSwspZDEN6r1WxnZsU9kT8MHrb9qpzsMOMzsotVzToEjgMtxIeoRfqFSoK8ZfUXBkSw__qxVyIe1lCs96-I--ufZSyO2pBe2kfau-ah7eR5-9oopxX6x1k0tzFHAk6Y3_jMqGysES_GmmfeUJvXXFIR35Rc-IaxU1igswmL2h1IUS-0DQ98Tv_Gf3hirnS87SU87aSJhajgn2YmARXWc&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=5.3.0.0"
Run Code Online (Sandbox Code Playgroud)
看来要使用await _interaction.GetAuthorizationContextAsync(returnUrl);returnUrl 检索授权上下文必须是整个 url"/connect/authorize/callback?..."
我试图进入异步的事情。我想让我的方法之一异步,因为它需要一段时间才能完成,所以我尝试了这个:
public static async Task GenerateExcelFile(HashSet<string> codes, ContestViewModel model)
{
var totalCodeToDistribute = model.NbrTotalCodes - (model.NbrCodesToPrinter + model.NbrCodesToClientService);
if (model.NbrTotalCodes > 0)
{
using (var package = new ExcelPackage())
{
await DoStuff(some, variables, here);
package.SaveAs(fileInfo);
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以我可以像这样在我的控制器中调用它:
await FilesGenerationUtils.GenerateExcelFile(uniqueCodesHashSet, model);
Run Code Online (Sandbox Code Playgroud)
但是当涉及到“await”关键字时,它说“Type void is not awaitable”
这是等待 void 方法的一种方式还是不是最佳实践?如果是这样,最好的方法是什么?
编辑:控制器:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(ContestViewModel model)
{
var contentRootPath = _hostingEnvironment.ContentRootPath;
DirectoryUtils.OutputDir = new DirectoryInfo(contentRootPath + Path.DirectorySeparatorChar
+ "_CodesUniques" + Path.DirectorySeparatorChar
+ model.ProjectName +
Path.DirectorySeparatorChar
+ "_Codes");
var …Run Code Online (Sandbox Code Playgroud) .net ×1
angular ×1
angular-i18n ×1
asp.net-core ×1
asp.net-mvc ×1
async-await ×1
asynchronous ×1
c# ×1
core ×1
locale ×1
rider ×1