Base solution for your next web application

Activities of "nancyphan"

Could you help me. I using template ASP.Net Boilerplate framework. I config in web module like that:

public override void PreInitialize()
        {
            //Enable database based localization
            Configuration.Modules.Zero().LanguageManagement.EnableDbLocalization();

            //Configure navigation/menu
            Configuration.Navigation.Providers.Add<LabourXchangeAPINavigationProvider>();
            Configuration.Modules.AbpWeb().AntiForgery.IsEnabled = false;
            Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true;
            //Configuration.Modules.AbpMvc().IsValidationEnabledForControllers = true;
            //Configure Hangfire - ENABLE TO USE HANGFIRE INSTEAD OF DEFAULT JOB MANAGER
            //Configuration.BackgroundJobs.UseHangfire(configuration =>
            //{
            //    configuration.GlobalConfiguration.UseSqlServerStorage("Default");
            //});
            var cors = new EnableCorsAttribute("*", "*", "*");
            Configuration.Modules.AbpWebApi().HttpConfiguration.EnableCors(cors);

        };

and web.config:

<customErrors mode="Off" />

I created user and it is invalid email but it not to show detail message of validation errors. It show the message below:

Abp.Runtime.Validation.AbpValidationException: Method arguments are not valid! See ValidationErrors for details.
   at Abp.Runtime.Validation.Interception.MethodInvocationValidator.Validate() in D:\Github\aspnetboilerplate\src\Abp\Runtime\Validation\Interception\MethodInvocationValidator.cs:line 94
   at Abp.WebApi.Validation.AbpApiValidationFilter.<ExecuteActionFilterAsync>d__5.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Api\WebApi\Validation\AbpApiValidationFilter.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Abp.WebApi.Auditing.AbpApiAuditFilter.&lt;ExecuteActionFilterAsync&gt;d__4.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Api\WebApi\Auditing\AbpApiAuditFilter.cs:line 47
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Abp.WebApi.Auditing.AbpApiAuditFilter.&lt;ExecuteActionFilterAsync&gt;d__4.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Api\WebApi\Auditing\AbpApiAuditFilter.cs:line 53
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Abp.WebApi.Security.AntiForgery.AbpAntiForgeryApiFilter.&lt;ExecuteAuthorizationFilterAsync&gt;d__10.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Api\WebApi\Security\AntiForgery\AbpAntiForgeryApiFilter.cs:line 51
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Abp.WebApi.Authorization.AbpApiAuthorizeFilter.<ExecuteAuthorizationFilterAsync>d__7.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Api\WebApi\Authorization\AbpApiAuthorizeFilter.cs:line 69
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.AuthenticationFilterResult.&lt;ExecuteAsync&gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
WARN  2017-06-12 21:32:29,143 [71   ] nHandling.AbpApiExceptionFilterAttribute - There are 1 validation errors:
WARN  2017-06-12 21:32:29,143 [71   ] nHandling.AbpApiExceptionFilterAttribute - The EmailAddress field is not a valid e-mail address. (input.EmailAddress)

Please help me to fix this problem :( Many thanks in advance

Hi I want to confirm email after register user. But when i confirm email by code and user id it return "invalid token" although i confirm the same code. Please help me to fix it. Thanks

This is my code:

public class UserAppService : DemoAPIAppServiceBase, IUserAppService
    {
        private readonly IRepository<User, long> _userRepository;
        private readonly UserManager _userManager;

        public static IDataProtectionProvider DataProtectionProvider { get; private set; }

        public UserAppService(IRepository<User, long> userRepository, UserManager userManager)
        {
            _userRepository = userRepository;
            _userManager = userManager;
            DataProtectionProvider = new DpapiDataProtectionProvider("LabourXchange");
            if (_userManager.UserTokenProvider == null)
            {
                _userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long (DataProtectionProvider.Create("EmailConfirmation"));
            }
        }
public async Task<UserDto> CreateUser(CreateCandidateUserInput input)
        {

            var user = new User
            {
                UserName = input.EmailAddress,
                Name = input.Name,
                Surname = input.Surname,
                EmailAddress = input.EmailAddress,
                Password = new PasswordHasher().HashPassword(input.Password),
                IsActive = true
            };
            //Add default roles
            user.Roles = new List<UserRole> { new UserRole { RoleId = input.RoleId } };
            //Save user
            CheckErrors(await _userManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync();   
            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user.Id);
            code = HttpUtility.UrlEncode(code);
            var callbackUrl = ConfigurationManager.AppSettings["LinkClient"];
            callbackUrl = "user/signup/confirmEmail/?id=" + user.Id + "&code=" + code;
            string path = HttpContext.Current.Server.MapPath("~/Templates/Signup/User/ConfirmationRegisterationEmail.html");

            var emailInput = new ConfirmationRegisterationEmailInput
            {
                EmailAddress = user.EmailAddress,
                Link = callbackUrl,
                Name = user.Name,
                Subject = "Confirmation register user",
                Path = path
            };
            SendConfirmationRegisterationEmail(emailInput);
            return user.MapTo<UserDto>();
        }
public async Task ConfirmEmail(int id, string code)
        {
            var user = await _userManager.GetUserByIdAsync(id);
            var decode = HttpUtility.UrlDecode(code);
            var result = await _userManager.ConfirmEmailAsync(id, decode);
            if (result .Success)
            {
                user.IsEmailConfirmed = true;

                await _userManager.UpdateAsync(user);
                await CurrentUnitOfWork.SaveChangesAsync();
            }
        }

==> result: Invalid token. I don't know why. Would you help me this problem, thanks you very much.

Showing 1 to 2 of 2 entries