小编Joh*_*yer的帖子

InvalidOperationException: Can't use schemaId .. 相同的 schemaId 已用于类型

我收到以下错误。

InvalidOperationException: Can't use schemaId "$Registration" for type "$PortalService.Models.Registration". The same schemaId is already used for type "$PortalService.Models.Registration"
Run Code Online (Sandbox Code Playgroud)

我已经尝试了以下链接中的建议,但没有成功。

招摇错误:冲突的schemaIds:检测到类型A和B的重复schemaIds

我在模型中只有一个注册类。我曾尝试重命名课程但没有成功。

我正在使用 OData .Net Core 3.1 项目。

配置 Swagger 如下

 services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
            services.AddSwaggerGen(c =>
            {
                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = @"JWT Authorization header using the Bearer scheme. \r\n\r\n 
                      Enter 'Bearer' [space] and then your token in the text input below.
                      \r\n\r\nExample: 'Bearer 12345abcdef'",
                    Name = "Authorization",
                    In = ParameterLocation.Header,
                    Type = SecuritySchemeType.ApiKey,
                    Scheme = "Bearer"
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement()
                  { …
Run Code Online (Sandbox Code Playgroud)

c# odata swagger asp.net-core-3.1

11
推荐指数
3
解决办法
9285
查看次数

从 Identity Server 4 注销不会从客户端注销

我有一个与https://github.com/IdentityServer/IdentityServer4/issues/3153类似的问题

我正在使用 Asp Net Identity 和 EF Core 组合示例,一切正常,数据库、播种、api 调用,除了我尝试从 IS 页面注销时。它不会删除.AspNetCore.Cookies保持用户登录客户端的那个。

    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<IActionResult> Logout(LogoutInputModel model)
    {

        // build a model so the logged out page knows what to display
        var vm = await BuildLoggedOutViewModelAsync(model.LogoutId);

        if (User?.Identity.IsAuthenticated == true)
        {
            _log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + "Logout: User Is Authenticated" + "</AUDIT>");

            try
            {
                await _signInManager.SignOutAsync();
                await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
                await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
                // raise the logout event
                await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
            }
            catch (NotSupportedException)
            {
                _log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + …
Run Code Online (Sandbox Code Playgroud)

security .net-core identityserver4 angular

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

如何修改OData .net core中Delta Patch中的对象

我有一个与补丁操作中的增量相关的问题。我想拦截该对象并更新属性

Bacteria.nameShort = HTMLExtractHelper.RemoveUnwantedTags(Bacteria.name);

在每个更新/补丁上。

我可以在 put 和 post 动词中轻松完成这些操作,但 Delta 对象似乎阻止我更新补丁中的属性。

public async Task<IActionResult> Patch([FromODataUri] int key, [FromBody] Delta<Bacteria> Bacteria)
{
  if (!ModelState.IsValid)
  {
    return BadRequest(ModelState);
  }
  //var entity = await _db.Bacterias.FindAsync(key);
  var entity = _db.Bacterias.FirstOrDefault(i => i.bacteriaID == key);
  if (entity == null)
  {
    return NotFound();
  }

  Bacteria.Patch(entity);
  try
  {
    await _db.SaveChangesAsync();
  }
  catch (DbUpdateConcurrencyException)
  {
    if (!BacteriaExists(key))
    {
      return NotFound();
    }
    else
    {
      throw;
    }
  }

  return Updated(entity);
}
Run Code Online (Sandbox Code Playgroud)

如何实现更新控制器补丁功能中的属性?

patch odata .net-core asp.net-core-webapi

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