我在 azure 上有一个运行 .net core api 的 appservice。
在我的 appsettings.json 文件中,我有一个类似于以下内容的部分:
"Serilog": {
"LevelSwitches": { "$controlSwitch": "Information" },
"MinimumLevel": {
"ControlledBy": "$controlSwitch",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "LOGS\\log.json",
"rollingInterval": "Day",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
},
{
"Name": "Seq",
"Args": {
"serverUrl": "https://MyLoggingServer",
"apiKey": "AAAAAAAAAAAAAAAAA",
"controlLevelSwitch": "$controlSwitch"
}
}
]}
Run Code Online (Sandbox Code Playgroud)
在 azure 门户的 azure appsetting 部分中,我不确定如何设置 apiKey,在其他更简单的设置中,我在 appsettings.json 中有另一个部分
"CustomSettings": {
"MySpecificSetting": "ABCDEFG",
}
Run Code Online (Sandbox Code Playgroud)
然后在 azure 门户中,我可以通过执行以下操作来设置设置
CustomSettings:MySpecificSetting
Run Code Online (Sandbox Code Playgroud)
但我不确定这种语法如何允许我访问 writeTo …
使用ASP网络核心身份-用户提供密码和用户名以获取jwt令牌时,他们会将凭据发布到/ api / token
我的令牌控制器方法应该使用Usermanager来通过CheckPasswordAsync来检查密码,如果通过则返回令牌,还是应该使用signinmanager并调用PasswordSignInAsync然后根据该结果返回令牌?
我看到了两者的示例,并且想知道每种方法都有什么好处,一种方法比另一种方法更好吗?
目前,我们团队中的某人已撰写以下内容:
[AllowAnonymous]
[HttpPost]
public async Task<ActionResult<User>> Post([FromBody]User model)
{
try
{
var user = await _userManager.FindByNameAsync(model.Username);
if (user == null)
return StatusCode(StatusCodes.Status401Unauthorized, "Incorrect username or password");
var passwordOK = await _userManager.CheckPasswordAsync(user, model.Password);
if (!passwordOK)
return StatusCode(StatusCodes.Status401Unauthorized, "Incorrect username or password");
model.Id = user.Id;
model.Name = user.DisplayName;
model.Password = "";
int expiresIn;
long expiresOn;
model.Token = _authorisationService.GetJWTToken(model.Username, user.Id, out expiresIn, out expiresOn);
model.ExpiresIn = expiresIn;
model.ExpiresOn = expiresOn;
return model;
}
catch (Exception)
{
// …Run Code Online (Sandbox Code Playgroud) 我有使用vue cli 3的vue应用程序。在设置过程中,我选择了jest作为测试框架。为了运行我的单元测试,我在package.json中有一个脚本:
test:unit": "vue-cli-service test:unit",
Run Code Online (Sandbox Code Playgroud)
并运行它,我在vs代码终端中编写:
npm run test:unit
Run Code Online (Sandbox Code Playgroud)
这将运行我所有符合package.json文件的jest config部分中设置的规范的测试。
我的问题是如何仅运行一个测试。我需要运行特定的命令吗?或者是否有适用于此设置的vscode扩展名。
我有一个按照这篇博客文章实现的 serilog 中间件类https://blog.datalust.co/smart-logging-middleware-for-asp-net-core/
如果我想多次使用 LogContext.PushProperty 在日志记录中推送各种信息,我只需要将以下代码放入我的 Invoke 方法中:
LogContext.PushProperty("Address", httpContext.Connection.RemoteIpAddress);
LogContext.PushProperty("Username", httpContext.User.Identity.IsAuthenticated ? httpContext.User.Identity.Name : null);
Run Code Online (Sandbox Code Playgroud)
LogContext.PushProperty 的文档仅显示添加一个属性,并表示要使用 using 块,还是我需要执行以下操作:
using (LogContext.PushProperty("Address",
httpContext.Connection.RemoteIpAddress))
using (LogContext.PushProperty("Username", httpContext.User.Identity.IsAuthenticated ? httpContext.User.Identity.Name : null))
{ //rest of invoke method here }
Run Code Online (Sandbox Code Playgroud) 我有一个显示列表的组件。我还有另一个组件,它也显示一个列表。它们一起坐在另一个组件上,例如:
<template>
<div>
<my-component-1 :items="listItems1"/>
<my-component-2 :items="listItems2"/>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
是否可以使用诸如 vue-draggable 之类的库将项目从一个组件拖到另一个组件?
谢谢
我从我的 api 获取日期,我得到的格式是"2019-04-17T15:04:28"
日期是 UTC。我回来的日期应该在末尾有 Z 还是无关紧要。如果Z不存在,Javascript日期函数会显示不正确吗?
谢谢@Esko,谢谢我认为,如果您startup.cs通过以下方式更改 json 序列化程序选项,那么在 .net 核心中的困惑是:
AddJsonOptions(opt =>{
opt.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat;
});
Run Code Online (Sandbox Code Playgroud)
Visual Studio 中的工具提示说
但它没有打开 Z 并且文档也没有显示 Z ( https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_DateFormatHandling.htm )
相反,我将尝试设置一个不同的选项
opt.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
Run Code Online (Sandbox Code Playgroud) 我在模态上有一个 bootstrap-vue 输入
<b-form-input id="inputText1" ref="inputText1" v-model="inputText" autofocus></b-form-input>
Run Code Online (Sandbox Code Playgroud)
该模态是 bootstrap-vue 模态,显示/隐藏由 v-if 指令控制。
当模式打开时,输入具有焦点。如果我关闭模式,输入将不再具有焦点。
我尝试在每次安装模式时设置自动对焦属性,但它仍然不聚焦。我也尝试过使用 $nextTick 。
我有自定义组件的输入,当我单击包装器组件上的下一个按钮时,我需要向父组件发送详细信息。
这在 vue 中怎么可能?
包装器.vue
<template>
<div :id="contentId" class="mt-3">
<div>
<slot></slot>
</div>
<b-row class="float-right">
<b-col>
<button cssClass="e-outline" v-on:click="btnNext">{{nextButtonText}}</button>
</b-col>
</b-row>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
父.vue
<template>
<div>
<Wrapper contentId="1">
<CustomComponent1 />
</wrapper>
<Wrapper contentId="2">
<CustomComponent1 />
</wrapper>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
customComponent1.vue
<template>
<div>
<input v-model="name" />
<input v-model="name2" />
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
上面的代码是为了说明目的。
我正在使用 bootstrap-vue 包并有一个复选框,如下所示:
<b-form-checkbox v-model="isSelected"switch></b-form-checkbox>
Run Code Online (Sandbox Code Playgroud)
我有数据属性
data(){
isSelected: false
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是让用户单击复选框,然后在更改选中的值之前通过调用方法执行某种验证。该方法然后可以防止值被改变。
我怎样才能做到这一点?
我试图将方法绑定到@change 事件,但是当我尝试设置this.isSelected = false复选框值时仍然被选中。
我正在尝试使用eshoponweb示例应用程序在Net Core 2.1中创建MVC应用程序。我已经读过,在实体框架核心中,放入存储库层并直接使用ef dbcontext没有太大好处。我将如何在干净的建筑场景中做到这一点。在示例应用程序中,dB上下文位于基础结构层中,而业务服务逻辑全部位于应用程序核心中。我曾考虑过将其中任何一个都搬走,但那不会阻止干净的架构想要实现的分离。https://github.com/dotnet-architecture/eShopOnWeb和https://www.thereformedprogrammer.net/is-the-repository-pattern-useful-with-entity-framework-core/
使用moment.js库说我有datetime今天的日期,我只想datetime用另一个值替换 的日期部分并保持时间部分相同
我不想减去或增加天数等 - 我有一个第 3 方时间选择器,当您选择一个时间时,它会创建一个datetime始终是当天的时间。我需要发送回不同的服务器datetime- 日期不同,但要保留选择器的时间部分。
示例代码:
let myDate = "2019-03-15T00:00:00"
let selectedDateTime = "2019-04-04T12:30:00"
Run Code Online (Sandbox Code Playgroud)
预期结果是:
"2019-03-15T12:30:00"
Run Code Online (Sandbox Code Playgroud)
谢谢
我刚开始使用 bitbucket,只是尝试设置简单的构建管道。单击管道菜单选项并编辑示例文件并提交。这在我的 master 分支上创建了一个管道 yaml 文件。它运行并构建正常 - 它没有构建我的开发分支。
我是否需要在每个分支上都有一个管道 yaml 文件。
我可以从文档中看到,我可以将分支特定步骤放入一个文件中,如果我编辑已在 master 上提交的文件以包含开发分支的部分,那么当我提交到开发分支或这只会在提交到 master 分支时触发。
let arr1 = [{itemId:1, name:"item1"}, {itemId:2, name:"item2"},{itemId:3, name:"item3"}]
let arr2 = [{id:1, name:"item1"}, {id:2, name:"item2"}]
Run Code Online (Sandbox Code Playgroud)
如何arr1根据在arr2哪里arr1.itemId等于的匹配项进行过滤arr2.id
因此,在这种情况下的预期结果将是:
[{itemId:1, name:"item1"}, {itemId:2, name:"item2"}]
Run Code Online (Sandbox Code Playgroud)
我已经尝试过搜索,因此如果存在问题可以将我指向正确的方向,这将对您有所帮助
谢谢
asp.net-core ×3
javascript ×3
vue.js ×3
c# ×2
ecmascript-6 ×2
vuejs2 ×2
architecture ×1
arrays ×1
azure ×1
azureportal ×1
ef-core-2.0 ×1
jestjs ×1
momentjs ×1
serilog ×1
structure ×1
vue-cli-3 ×1
yaml ×1