Base solution for your next web application

Activities of "khai"

Hello,

I am trying to config two things which are relevant to IConfigurationRoot to get config inside AppSettings.json.

  1. I want to inject IConfiguration to file AngularAppUrlService.cs. However, those fields are read-only therefore I cannot assign new value to it.

  2. I implement new class for Email Sender Service and I put it outside ASPNETZero Sourcecode. However, I cannot inject IConfigurationRoot to my class. I got this error.

Please help me to archive this. Thank you

For the first question, after I added setter to both of the override fields, I see that the instance of AppUrlService is NullAppUrlService and I cannot use it. Please help me to figure out that.

Hello, these are my files.

1. AppUrlServiceBase

public abstract class AppUrlServiceBase : IAppUrlService, ITransientDependency
    {
        public abstract string EmailActivationRoute { get; set; }

        public abstract string PasswordResetRoute { get; set; }

        protected readonly IWebUrlService WebUrlService;
        protected readonly ITenantCache TenantCache;

        protected AppUrlServiceBase(IWebUrlService webUrlService, ITenantCache tenantCache, IConfigurationRoot appConfigurationRoot)
        {
            WebUrlService = webUrlService;
            TenantCache = tenantCache;
            this.Initialize(appConfigurationRoot);
        }

        private void Initialize(IConfigurationRoot appConfigurationRoot)
        {
            EmailActivationRoute = appConfigurationRoot["WebUIConfig:EmailActivationRoute"];
            PasswordResetRoute = appConfigurationRoot["WebUIConfig:PasswordResetRoute"];
        }

        public string CreateEmailActivationUrlFormat(int? tenantId)
        {
            return CreateEmailActivationUrlFormat(GetTenancyName(tenantId));
        }

        public string CreatePasswordResetUrlFormat(int? tenantId)
        {
            return CreatePasswordResetUrlFormat(GetTenancyName(tenantId));
        }

        public string CreateEmailActivationUrlFormat(string tenancyName)
        {
            var activationLink = WebUrlService.GetSiteRootAddress(tenancyName).EnsureEndsWith('/') + EmailActivationRoute + "?userId={userId}&confirmationCode={confirmationCode}";

            if (tenancyName != null)
            {
                activationLink = activationLink + "&tenantId={tenantId}";
            }

            return activationLink;
        }

        public string CreatePasswordResetUrlFormat(string tenancyName)
        {
            var resetLink = WebUrlService.GetSiteRootAddress(tenancyName).EnsureEndsWith('/') + PasswordResetRoute + "?userId={userId}&resetCode={resetCode}";

            if (tenancyName != null)
            {
                resetLink = resetLink + "&tenantId={tenantId}";
            }

            return resetLink;
        }


        private string GetTenancyName(int? tenantId)
        {
            return tenantId.HasValue ? TenantCache.Get(tenantId.Value).TenancyName : null;
        }
    }

2. AngularAppUrlService

public class AngularAppUrlService : AppUrlServiceBase
    {
        public override string EmailActivationRoute { get; set; }

        public override string PasswordResetRoute { get; set; }

        public AngularAppUrlService(
                IConfigurationRoot appConfigurationRoot,
                IWebUrlService webUrlService,
                ITenantCache tenantCache
            ) : base(
                webUrlService,
                tenantCache,
                appConfigurationRoot
            )
        {
            
        }
    }

3. MvcAppUrlService (I don't see this file)

4. NullAppUrlService

public class NullAppUrlService : IAppUrlService
    {
        public static IAppUrlService Instance { get; } = new NullAppUrlService();

        private NullAppUrlService()
        {
            
        }

        public string CreateEmailActivationUrlFormat(int? tenantId)
        {
            throw new NotImplementedException();
        }

        public string CreatePasswordResetUrlFormat(int? tenantId)
        {
            throw new NotImplementedException();
        }

        public string CreateEmailActivationUrlFormat(string tenancyName)
        {
            throw new NotImplementedException();
        }

        public string CreatePasswordResetUrlFormat(string tenancyName)
        {
            throw new NotImplementedException();
        }
    }

hi, I am also waiting for V5 as our project need features of V5. hope that you release ASAP. not sure if it will be available next Monday, 20 Nov?

hi, we are working on project which need features of new metronic theme v5.x with angular 4, no sure when it live?

thx we want to have the calendar features on new metronic theme.

Hello, The error appears at runtime (it means I can compile it successfully). Is that a bug?

Hello, Does the Angular project support Server-rendering from ASPNET Core or NodeJS? I need this to increase the speed of loading the login page. Thanks.

<cite>ismcagdas: </cite> Hi @Khai,

No, it is not supported yet. We will work on it for the next releases.

OK I will be waiting for this feature. Thank you.

Hello, I want to ask a few questions about service in Application project.

1/ I am creating a service (let call it LibraryAppService) and in that service, I want to get the token from current request (or the UserId, TenantId to call other API - which can use the token that AspNetZero issued). How can I do that?

2/ I don't want to hardcode my other API URL inside the LibraryAppService but I want to put it inside AppSettings.json. How can I do that?

Thank you very much.

Showing 1 to 10 of 27 entries