Base solution for your next web application

Activities of "billyteng"

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? v 10.0.0
  • What is your product type (Angular or MVC)? Angular with separate host
  • What is product framework type (.net framework or .net core)? .Net 5

I got this screen shot problems after I downloaded and published to our local window server 2019. When I checked the log file , I found this errors.

WARN 2020-12-14 13:49:35,976 [1 ] tion.Repositories.EphemeralXmlRepository - Using an in-memory repository. Keys will not be persisted to storage. WARN 2020-12-14 13:49:35,990 [1 ] taProtection.KeyManagement.XmlKeyManager - Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits. WARN 2020-12-14 13:49:42,161 [1 ] taProtection.KeyManagement.XmlKeyManager - No XML encryptor configured. Key {0ad90ef4-9ed7-4b48-b631-3c0461b45c1c} may be persisted to storage in unencrypted form.

How to solve this problems?

Thanks & Best Regards

Answer

Hi Velu,

How did you solve your above problems? I also encountered that problems. Could you please share the solutions with us ?

Thanks

HI ismcagdas,

I downloaded separate angular and .net 5 version from https://aspnetboilerplate.com/Templates. When we uploaded host project on our server and tested, no problems . Any suggestions?

Thanks

Hi ismcagdas,

I added the services.AddDataProtection at web.host project's ConfigureServices and tested. Key file is generated to specific location and not working on Server. I still got same problems. Do I need to amend another class or any files? Please kindly advice.

Thanks

Hi ismcagdas,

Any suggestions for this problems ? We still cannot solve yet.

Thanks

Hi ismcagdas ,

When will release 10.1 and this removing table prefix fix in 10.1 version?

Thanks

What is your product version? 10.1 What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .net 5

After I downloaded latest version 10.1 and run Update-Database to create database, db is successfully created. Then I added modelBuilder.ChangeAbpTablePrefix<Tenant, Role, User>("") to remove abp prefix. I run Add-Migration "Remove_ABP_Prefix" first then run Update-Database. I got this screen shot errors. Do I need to change anything?

  • What is your product version?
  • Product Version is 10.0.0
  • What is your product type (Angular or MVC)?
  • Angular
  • What is product framework type (.net framework or .net core)?
  • .net core
  • What is ABP Framework version?
  • 6.1

I need some data to store in session which is reuse after logined. I had override CreateAsync(User user) method in UserClaimsPrincipalFactory.cs. Look it

public override async Task CreateAsync(User user)

{
var claim = await base.CreateAsync(user);
        var resObj = (from res in _reservationRepository.GetAll()
                      join gs in _guestRepository.GetAll() on res.GuestKey equals gs.Id
                      join r in _roomRepository.GetAll() on res.RoomKey equals r.Id
                      where (res.Status == 1 || res.Status == 2) && (gs.EMail == user.EmailAddress || gs.LastName == user.UserName)
                      select new 
                      {
                          DocNo = res.DocNo,
                          ReservationKey = res.Id,
                          GuestKey = gs.Id
                      }).FirstOrDefault();
        if (resObj != null)
        {
            claim.Identities.First().AddClaim(new Claim("Application_DOCNO", resObj.DocNo));
        }

        return claim;// it is ok. Docno value have in claims.
    }

Then I created MyAppSession Class folowing :

    public class MyAppSession : ClaimsAbpSession, ITransientDependency,IMyAppSession
{
    public MyAppSession(
    IPrincipalAccessor principalAccessor,
    IMultiTenancyConfig multiTenancy,
    ITenantResolver tenantResolver,
    IAmbientScopeProvider<SessionOverride> sessionOverrideScopeProvider) :
    base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider)
    {
    }
    public string DOCNO
    {
        get
        {
            var userDocClaim = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "Application_DOCNO");
            if (userDocClaim == null || string.IsNullOrEmpty(userDocClaim?.Value))
            {
                return null;
            }

            return userDocClaim.Value;
        }

    }

This is IMyAppSession Interface

public interface IMyAppSession
{
string DOCNO { get; }
}

This is session value retrive class

public class TokenAuthController : BEZNgCoreControllerBase
{
private readonly IMyAppSession \_p;
public TokenAuthController(IMyAppSession p)
{
\_p = p;
}
    public string GetSession()
    {
        return _p.DOCNO;// Here value is null. Why?
    }
}

Is there anything need to change? Please help me.

Hi Zony, Thanks for your reply. I did your follow. But it's still null value. Not show "Hello World". Look my code.

In Application layer public class NameNgCoreApplicationModule : AbpModule { public override void PreInitialize() { //Adding authorization providers Configuration.Authorization.Providers.Add<AppAuthorizationProvider>();

        //Adding custom AutoMapper configuration
        Configuration.Modules.AbpAutoMapper().Configurators.Add(CustomDtoMapper.CreateMappings);

        //For CustomClaimFactory
        IocManager.IocContainer.Register(
        Component
            .For&lt;IUserClaimsPrincipalFactory&lt;User&gt;, CustomClaimFactory>()
            .LifestyleTransient()
            .IsDefault());
    }

    public override void Initialize()
    {
        IocManager.RegisterAssemblyByConvention(typeof(BEZNgCoreApplicationModule).GetAssembly());
    }
}

I created "CustomClaimFactory" class in NameNgCore.Core project.

public class CustomClaimFactory : AbpUserClaimsPrincipalFactory<User, Role> { private readonly IRepository<Guest, Guid> _guestRepository; private readonly IRepository<Reservation, Guid> _reservationRepository; private readonly IRepository<Room, Guid> _roomRepository;

    public CustomClaimFactory(AbpUserManager&lt;Role, User&gt; userManager,
    AbpRoleManager&lt;Role, User&gt; roleManager,
    IOptions&lt;IdentityOptions&gt; optionsAccessor,
    IRepository&lt;Guest, Guid&gt; guestRepository,
    IRepository&lt;Reservation, Guid&gt; reservationRepository,
    IRepository&lt;Room, Guid&gt; roomRepository

        ) : base(userManager,
    roleManager,
    optionsAccessor)
    {
        _guestRepository = guestRepository;
        _reservationRepository = reservationRepository;
        _roomRepository = roomRepository;
    }
    public override async Task&lt;ClaimsPrincipal&gt; CreateAsync(User user)
    {
        var claim = await base.CreateAsync(user);

        var resObj = (from res in _reservationRepository.GetAll()
                      join gs in _guestRepository.GetAll() on res.GuestKey equals gs.Id
                      join r in _roomRepository.GetAll() on res.RoomKey equals r.Id
                      where (res.Status == 1 || res.Status == 2) && (gs.EMail == user.EmailAddress || gs.LastName == user.UserName)
                      select new
                      {
                          DocNo = res.DocNo,
                          ReservationKey = res.Id,
                          GuestKey = gs.Id
                      }).FirstOrDefault();
         // resObj has value             
        if (resObj != null)
        {
            claim.Identities.First().AddClaim(new Claim("Application_DOCNO", "Hello World"));
          
        }           

        return claim;
    }
}

public interface IMyAppSession
{
    string DOCNO { get; }      
}

public class MyAppSession : ClaimsAbpSession, ITransientDependency,IMyAppSession { public MyAppSession( IPrincipalAccessor principalAccessor, IMultiTenancyConfig multiTenancy, ITenantResolver tenantResolver, IAmbientScopeProvider<SessionOverride> sessionOverrideScopeProvider) : base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider) { } public string DOCNO { get {
var userDocClaim = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "Application_DOCNO"); if (userDocClaim == null || string.IsNullOrEmpty(userDocClaim?.Value)) { return null; }

            return userDocClaim.Value;                
        }

    }
 }
 
 This is TokenAuthController in NameNgCore.Web.Core project
 which  call store values
 
  public class TokenAuthController : NameNgCoreControllerBase
{
private readonly IUserClaimsPrincipalFactory&lt;User&gt; _iclaimsPrincipalFactory;
private readonly IMyAppSession _p;
public TokenAuthController(IMyAppSession p,
        IUserClaimsPrincipalFactory&lt;User&gt; iclaimsPrincipalFactory
)
{
 _p = p;
        _iclaimsPrincipalFactory = iclaimsPrincipalFactory;
}

 [HttpPost]
    public async Task&lt;AuthenticateResultModel&gt; Authenticate([FromBody] AuthenticateModel model)
    {
        your code ...ok....then.......
        var loginResult = await GetLoginResultAsync(
            model.UserNameOrEmailAddress,
            model.Password,
            GetTenancyNameOrNull()
        );
        ..........
         var refreshToken = CreateRefreshToken(await CreateJwtClaims(loginResult.Identity, loginResult.User,
            tokenType: TokenType.RefreshToken));
        var accessToken = CreateAccessToken(await CreateJwtClaims(loginResult.Identity, loginResult.User,
            refreshTokenKey: refreshToken.key));
            
        var claims = await _iclaimsPrincipalFactory.CreateAsync(loginResult.User);

        var d =_p.DOCNO ; // here value is null. Actually it must show "Hello World" 
        
        return new AuthenticateResultModel
        {
            AccessToken = accessToken,
            ExpireInSeconds = (int)_configuration.AccessTokenExpiration.TotalSeconds,
            RefreshToken = refreshToken.token,
            RefreshTokenExpireInSeconds = (int)_configuration.RefreshTokenExpiration.TotalSeconds,
            EncryptedAccessToken = GetEncryptedAccessToken(accessToken),
            TwoFactorRememberClientToken = twoFactorRememberClientToken,
            UserId = loginResult.User.Id,
            ReturnUrl = returnUrl
        };
    }
}

please help me..Is there anything path?

I have alread sent the files to your [email protected]. Please check it.

Showing 1 to 10 of 43 entries