DTO:
using Abp.Runtime.Validation;
using MyCompany.MyProject.Dto;
namespace MyCompany.MyProject.Business.Dto.Tests
{
public class FetchTestInput: PagedAndSortedInputDto, IShouldNormalize
{
public int TestLevel { get; set; }
public int CodeType { get; set; }
public string TestCode { get; set; }
public string DescLong { get; set; }
public string LanguageCode { get; set; }
public string TestParent { get; set; }
public int? TestCondID { get; set; }
public int? TestResultId { get; set; }
public void Normalize()
{
if (string.IsNullOrEmpty(Sorting))
{
Sorting = "TestCode";
}
}
}
}
API method:
public PagedResultDto<FetchTest> GetSearchTest(FetchTestInput searchInput)
{
return _TestRepository.GetSearchTest(searchInput);
}
Entity:
using Abp.Domain.Entities.Auditing;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyCompany.MyProject.Business.Model.Tests
{
[Table("Test")]
public class Test : FullAuditedEntity
{
public const int NVarcharLength3 = 3;
public const int NVarcharLength40 = 40;
public const int NVarcharLength250 = 250;
[Required]
[MaxLength(NVarcharLength250)]
public string TestCode { get; set; }
[Required]
public int TestLevel { get; set; } = 0;
[MaxLength(NVarcharLength250)]
public string TestParent { get; set; }
[Required]
public int CodeType { get; set; } = 0;
[MaxLength(NVarcharLength3)]
public string CurrencyCode { get; set; }
[Required]
[MaxLength(NVarcharLength40)]
public string DescLong { get; set; }
[Required]
[MaxLength(NVarcharLength40)]
public string DescShort { get; set; }
[Required]
public bool FlgAllow1 { get; set; } = true;
[Required]
public bool FlgAllow2 { get; set; } = false;
[Required]
public bool FlgAllow3 { get; set; } = false;
[Required]
public bool FlgAllow4 { get; set; } = true;
[Required]
public bool FlgAllow5 { get; set; } = true;
[Required]
public bool FlgFood6 { get; set; } = true;
[Required]
public bool Flg7 { get; set; } = true;
[Required]
public bool Flg8 { get; set; } = false;
[Required]
public decimal MaxPrice { get; set; } = 0;
[Required]
public int TestMemberId { get; set; } = 0;
[Required]
public decimal MinPrice { get; set; } = 0;
public int? TestDiscountId { get; set; }
public int? TestDataCode { get; set; }
}
}
Please find the attached screenshot for your reference.
But APIs are getting random required fields which I have not even mentioned in DTO. due to this most of the APIs call are getting failed.
Thanks
Solved issue buddy.
Thanks
@aaron any updates?
@aaron
ABP version : 3.2.5
I have checked, I have v5.0.4 version.
Thanks
@aaron
Please help buddy
<cite>aaron: </cite> Which ABP version and ASP.NET Zero version is this?
How to check ABP version and ASP.NET Zero version?
Because I'm not sure about the project version.
I have completely different AuthConfigurer.cs file which I'm using in my project.
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Runtime.Security;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
namespace Nec.Stanchion.Web.Startup
{
public static class AuthConfigurer
{
public static void Configure(IServiceCollection services, IConfiguration configuration)
{
var authenticationBuilder = services.AddAuthentication();
if (bool.Parse(configuration["Authentication:JwtBearer:IsEnabled"]))
{
authenticationBuilder.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
// The signing key must match!
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(configuration["Authentication:JwtBearer:SecurityKey"])),
// Validate the JWT Issuer (iss) claim
ValidateIssuer = true,
ValidIssuer = configuration["Authentication:JwtBearer:Issuer"],
// Validate the JWT Audience (aud) claim
ValidateAudience = true,
ValidAudience = configuration["Authentication:JwtBearer:Audience"],
// Validate the token expiry
ValidateLifetime = true,
// If you want to allow a certain amount of clock drift, set that here
ClockSkew = TimeSpan.Zero
};
options.Events = new JwtBearerEvents
{
OnMessageReceived = QueryStringTokenResolver
};
});
}
if (bool.Parse(configuration["IdentityServer:IsEnabled"]))
{
authenticationBuilder.AddIdentityServerAuthentication("IdentityBearer", options =>
{
options.Authority = configuration["App:ServerRootAddress"];
options.RequireHttpsMetadata = false;
});
}
}
/* This method is needed to authorize SignalR javascript client.
* SignalR can not send authorization header. So, we are getting it from query string as an encrypted text. */
private static Task QueryStringTokenResolver(MessageReceivedContext context)
{
if (!context.HttpContext.Request.Path.HasValue ||
!context.HttpContext.Request.Path.Value.StartsWith("/signalr"))
{
//We are just looking for signalr clients
return Task.CompletedTask;
}
var qsAuthToken = context.HttpContext.Request.Query["enc_auth_token"].FirstOrDefault();
if (qsAuthToken == null)
{
//Cookie value does not matches to querystring value
return Task.CompletedTask;
}
//Set auth token from cookie
context.Token = SimpleStringCipher.Instance.Decrypt(qsAuthToken, AppConsts.DefaultPassPhrase);
return Task.CompletedTask;
}
}
}
@aaron Please help buddy