小编Mig*_*ura的帖子

在Azure DevOps中使用新的部署作业。找不到文物

我需要使用Azure Devops将Asp.Net核心应用程序部署到Azure WebApp。

我有以下工作的Azure-Pipelines YAML文件:

trigger:
- master

variables:
  buildConfiguration: 'Release'
  buildPlatform: 'any cpu'
  version: '0.2.0'

stages:

- stage: 'Stage1'

  jobs:

  # Previous Jobs like Build, Test, ...

  - job: 'Publish'
    pool:
      vmImage: 'Ubuntu-16.04'
    dependsOn: 'Test'
    steps:

    - task: DotNetCoreCLI@2
      displayName: 'Publish'
      inputs:
        command: publish
        publishWebProjects: false
        projects: '**/*.csproj'
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
        zipAfterPublish: true

    - task: PublishBuildArtifacts@1
      displayName: 'Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'

    - task: AzureRmWebAppDeployment@4
        displayName: 'Deploy'
        inputs:
          package: '$(build.artifactstagingdirectory)/App.Api.zip'
          azureSubscription: 'MyName.Azure'
          appType: 'Web App On Windows'
          webAppName: …
Run Code Online (Sandbox Code Playgroud)

azure-deployment azure-devops azure-pipelines

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

禁用时,表单控件值在 OnSubmit 时变为 null

我有以下 Angular 7 形式:

ngOnInit() {

  this.organizationId = 1; // Used for testing

  this.form = this.formBuilder.group({     
    name: [''],
    organizationId: [{ value: this.organizationId, disabled: this.enableOrganizationChange }],
    start: ['']
  });

}
Run Code Online (Sandbox Code Playgroud)

在 HTML 中我使用的是Selectfor OrganizationId。它按预期被禁用。

然而,提交时该值null不是 1:

onSubmit() {

  if (this.form.valid) {

    this.submitting = true;

    console.log(this.form.value.organizationId);

    let request: Request = { 
      name: this.form.value.name,
      organizationId: this.form.value.organizationId.value,
      start: this.form.value.start
    };

  }

}
Run Code Online (Sandbox Code Playgroud)

为什么记录的值是null而不是1

我使用禁用只是为了避免用户更改值。

但我仍然需要提交时的值...

angular angular-reactive-forms angular7

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

NgIf 和零:为什么模板没有被渲染?

我在 Angular 组件上有以下可观察的内容:

count$: Observable<number>;

this.count$ = this.getCount();
Run Code Online (Sandbox Code Playgroud)

通过使用以下内容,我得到值 0(零);

this.count$.subscribe(x => console.log(x));
Run Code Online (Sandbox Code Playgroud)

在模板上我有:

<a routerLink="/dash" *ngIf="(count$ | async)">
  <ng-container *ngIf="count$ | async as count">
    Count: {{count}}
  </ng-container>
</a> 
Run Code Online (Sandbox Code Playgroud)

如果count$是 1,我得到Count: 1,但如果count$是 0,内容Count: 0甚至不会呈现。

知道为什么吗?

angular-template angular-ng-if angular

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

在控制器之外获取当前用户

在 ASP.NET Core 2.2 控制器上,我有以下内容:

var principal = this.User as ClaimsPrincipal;

var authenticated = this.User.Identity.IsAuthenticated;

var claims = this.User.Identities.FirstOrDefault().Claims;

var id = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
Run Code Online (Sandbox Code Playgroud)

我能够检查用户是否是authenticated并获取claims包括id.

我怎么能Controller在我没有的地方之外做同样的事情this.User

c# asp.net-core asp.net-core-2.2

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

在 Azure 中托管 Asp.Net Core 3.0:HTTP 错误 500.31 - ANCM 无法找到本机依赖项

我正在尝试在 Azure 中托管 ASP.NET Core 3.0 API:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <IsPackable>false</IsPackable>
    <NeutralLanguage>en-US</NeutralLanguage>
    <LangVersion>latest</LangVersion>   
  </PropertyGroup>  

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.*" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.*" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.*" />
    <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.*" />
  </ItemGroup>       

</Project>
Run Code Online (Sandbox Code Playgroud)

但是当我运行 de application 时,我得到:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version …
Run Code Online (Sandbox Code Playgroud)

azure asp.net-core-3.0

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

文件夹未复制到输出目录

我在 ASP.NET Core 3.1 csproj 文件中有以下内容:

  <ItemGroup> 
    <Content Include="webroot\**"> 
      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
    </Content> 
  </ItemGroup>

  <Target Name="Approot" BeforeTargets="BeforeBuild;BeforePublish">
    <Exec WorkingDirectory="approot" Command="npm install" />
    <Exec WorkingDirectory="approot" Command="npm run build --prod" />
  </Target>
Run Code Online (Sandbox Code Playgroud)

我正在approot文件夹中构建客户端应用程序并将结果保存到 webroot 文件夹。

我需要将 webfoot 文件夹复制到输出目录...

问题

当我构建它时,文件被放置在 webfoot 文件夹中,但它没有被复制到输出中。

所以我需要再次重建它,以便将 webroot 文件夹复制到输出...

似乎在构建之后运行了 2 个 npm 命令,但我使用的是 BeforeBuild。

c# msbuild npm .net-core asp.net-core

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

令牌无效 - 观众“空”无效

我在 ASP.NET Core 3.1 项目上有以下 Identity Server 4 配置:

services
  .AddIdentityServer(y => {
    y.Events.RaiseErrorEvents = true;
    y.Events.RaiseInformationEvents = true;
    y.Events.RaiseFailureEvents = true;
    y.Events.RaiseSuccessEvents = true;
  })
  .AddDeveloperSigningCredential()
  .AddInMemoryPersistedGrants()
  .AddInMemoryIdentityResources(Config.IdentityResources())
  .AddInMemoryApiResources(Config.ApiResources())
  .AddInMemoryApiScopes(Config.GetApiScopes())
  .AddInMemoryClients(Config.Clients)
  .AddProfileService<ProfileService>()
  .AddAspNetIdentity<User>();
Run Code Online (Sandbox Code Playgroud)

Config如下:

public static class Config {

  public static List<ApiResource> ApiResources() {
    return new List<ApiResource> { 
      new ApiResource("api", "API Resource")
    };
  }

  public static List<ApiScope> ApiScopes() {
    return new List<ApiScope> { 
      new ApiScope("api", "API Scope") 
    };
  }

  public static List<IdentityResource> IdentityResources() {
    return new List<IdentityResource> …
Run Code Online (Sandbox Code Playgroud)

jwt asp.net-core identityserver4 asp.net-core-3.1

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

NetCore 6 - 将 null 文字或可能的 null 值转换为不可为 null 的类型

我将项目更新到 NetCore 6,但收到警告:

Converting null literal or possible null value to non-nullable type.
Run Code Online (Sandbox Code Playgroud)

例如在单元测试中:

String source = null;
String expect = null;

String actual = source.ToSafeBase64Url(); 
Run Code Online (Sandbox Code Playgroud)

我在代码的多个地方收到此警告。

我应该如何解决这个问题?

c# .net-core asp.net-core c#-10.0

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

如何在 .NET 交互式笔记本中包含项目引用?

使用 NET 6 我有以下项目结构:

nuget.config
project.code-workspace
- Core
  Core.csproj
- Api
  Api.csproj
- Sim
  notebook.ipynb
Run Code Online (Sandbox Code Playgroud)

notebook.ipynb现在在哪里:

#i "nuget:https://api.nuget.org/v3/index.json"

#r "nuget:Microsoft.Data.Analysis,0.*"

using System;
using Microsoft.Data.Analysis;

Console.WriteLine("Hello World!");
Run Code Online (Sandbox Code Playgroud)

如何在 中包含对 Core 和 Api 项目的项目引用notebook.ipynb

我需要使用notebook.ipynb.

c# dotnet-interactive .net-interactive polyglot-notebooks

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

Profile EntityFramework

我有以下示例代码:

  Context context = new Context();
  Repository repository = new Repository(context);

  Post post = repository.First<Post>(x => x.Id == 1);

  Model model = new Model {
    Created = cube.Created,
    Id = cube.Id,
    Name = cube.Name,
    Pack = cube.Pack.Id,
    Mimes = context.Files.Where(x => x.Id == 1).Select(x => x.Mime).ToList()
  };
Run Code Online (Sandbox Code Playgroud)

我需要找到哪些SQL查询被发送到数据库.

如何使用SQL Express和VS 2012配置EF查询?

这有什么工具吗?

sql entity-framework

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