Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

SMS is not working #8599


User avatar
0
nitinrpatel created

Hello, I want to integrate Twilio SMS in my portal for two factor authentication as well as sending SMS from portal to user. I am trying to follow the mentioned steps in the link below, but unable to find that code lines in my project so provide needful steps.

I am using ASP.NET MVC 5.x with AngularJS version.

https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Features-Angular-Two-Factor-Authentication#twilio-integration


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    ASP.NET MVC 5.x with AngularJS version.

    https://docs.aspnetzero.com/en/aspnet-mvc-angularjs/latest/Development-Guide-Mvc-Angularjs#sms-verification

    You should use IdentitySmsMessageService. https://github.com/aspnetzero/aspnet-zero/blob/e730d0a890bea0618fa3c7d6d099b676c06e7f90/src/MyCompanyName.AbpZeroTemplate.Core/Identity/IdentitySmsMessageService.cs#L8-L28

    You can refer to the source code of the net core version. https://github.com/aspnetzero/aspnet-zero-core/blob/c070574456/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Net/Sms/TwilioSmsSender.cs#L9

  • User Avatar
    0
    nitinrpatel created

    Hello, I have Implemened Twilio Sms Intregration Code For My Stsrem, After Implementing Given steps in above link, still I am getting error which i have attached below. Is There any other stpes which i have to follow?

    {"message":"An error has occurred.","exceptionMessage":"ComponentActivator: could not proxy Abp.WebApi.Controllers.Dynamic.DynamicApiController`1[[TechnoForms.Messages.IMessageAppService, TechnoForms.Application, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]]","exceptionType":"Castle.MicroKernel.ComponentActivator.ComponentActivatorException","stackTrace":"   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext)
       at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, Boolean ignoreParentContext)
       at Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments)
       at Castle.Windsor.WindsorContainer.Resolve(Type service)
       at Abp.Dependency.IocManager.Resolve(Type type)
       at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver, Type type)
       at Abp.WebApi.Controllers.AbpApiControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
       at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)
       at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()","innerException":{"message":"An error has occurred.","exceptionMessage":"Can't create component 'TechnoForms.Identity.TwilioSmsSenderConfiguration' as it has dependencies to be satisfied.
    
    'TechnoForms.Identity.TwilioSmsSenderConfiguration' is waiting for the following dependencies:
    - Service 'TechnoForms.Configuration.IAppConfigurationAccessor' which was not registered.
    ","exceptionType":"Castle.MicroKernel.Handlers.HandlerException","stackTrace":"   at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
       at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.Core.InterceptorReference.Castle.MicroKernel.IReference<Castle.DynamicProxy.IInterceptor>.Resolve(IKernel kernel, CreationContext context)
       at Castle.Windsor.Proxy.AbstractProxyFactory.ObtainInterceptors(IKernel kernel, ComponentModel model, CreationContext context)
       at Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, Object target, ComponentModel model, CreationContext context, Object[] constructorArguments)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)"}}
    
    
  • User Avatar
    0
    maliming created
    Support Team
    • Service 'TechnoForms.Configuration.IAppConfigurationAccessor' which was not registered.

    hi

    Please share the relevant service code.

  • User Avatar
    0
    nitinrpatel created

    Hello, I have made some changes in files to solve my issue. I had removed dependancy on "TwilioSmsSenderConfiguration" file and applied my credentials on "TwilioSmsSender" page as below.

    public class TwilioSmsSender : ISmsSender, ITransientDependency
        {
            public async Task SendAsync(string number, string message)
            {
                try
                {
                    TwilioClient.Init("AccountSid", "AuthToken");
    
                    MessageResource resource = await MessageResource.CreateAsync(
                    body: message,
                    @from: new Twilio.Types.PhoneNumber("SenderNumber"),
                    to: new Twilio.Types.PhoneNumber(number));
                }
                catch (Exception E)
                {
                    throw new UserFriendlyException(E.Message);
                }
            }
        }