Base solution for your next web application

Activities of "affern"

@ismcagdas, thanks. I don't need it now. But maybe I will need this in the future.

I installed a clean database, and now it works. Strange :? Is there any settings in db that can affect this?

Hi, @ismcagdas I have now moved all my code to the fresh template and created a test site in Azure and this works great: <a class="postlink" href="https://testvotechafrontwebapp.azurewebsites.net">https://testvotechafrontwebapp.azurewebsites.net</a>. So my code works.

I used the same code in my prod site with the same database, but I still get the same error. It must be something wrong with my settings in Azure. But I have verified that my App Secret, AppId and Valid OAuth Redirect URIs is correct. If my code works I guess it is no point to send my project to you? But I don't now what can be wrong?

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

I have created an issue here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/1174">https://github.com/aspnetzero/aspnet-ze ... ssues/1174</a>. Since this is happened in a new template, you don't have to share our project.

Hi @ismcagdas. No, it is no bug in your template. It is just in my solution. I tested your template without my code, and it works fine. But I have added a lot of fields to the User entity, and maybe that is the reason my solution don't work.

Hi @ismcagdas

I have now created a test app with my clean aspnetzero code just to verify that my Facebook settings was ok, and the test app worked great.

So now I have debugged my app in Azure, and I get an error in line 294 in TokenAuthController: loginResult = await _logInManager.LoginAsync(new UserLoginInfo(model.AuthProvider, model.ProviderKey, model.AuthProvider), GetTenancyNameOrNull());

ErrorMessage:

Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: GlobalOpinions.Authorization.Users.User, id: 88 at Abp.Domain.Repositories.AbpRepositoryBase2.<GetAsync>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserStore2.<GetUserNameFromDatabaseAsync>d__88.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserManager2.<UpdateAsync>d__47.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.AbpLogInManager3.<CreateLoginResultAsync>d__38.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.AbpLogInManager3.<LoginAsyncInternal>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.AbpLogInManager3.<LoginAsync>d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at GlobalOpinions.Web.Controllers.TokenAuthController.

I'm getting back an user in _userRegistrationManager.RegisterAsync in RegisterExternalUserAsync method, and the parameters model.AuthProvider and model.ProviderKey is ok. But the user is not created in db, and I can't understand why :?

If you do not have any tips on the error messages above, I will send you my project. I really appreciate that you will spend time looking at this :) Have a nice evening!

Hi @ismcagdas My social login buttons is visibile on the login-page but not in "Create profile" page. But this is maybe how it should be?

I can share my project via email, but maybe you can take a look at my page first: <a class="postlink" href="https://votecha.com">https://votecha.com</a> and see if there is something wrong. You can try to register or login with FB if you want. If you try to login with Facebook, I think you will get this error: "There is no entity User with id = 85!". My latest userId is 84, so I think the code tries to create a new user, but something goes wrong.

I'm going to integrate my solution with Facebook, so my users must be able to authenticate with Facebook. I need some data that is not mandatory in facebook's profile, so the user must be able to register the profile on my page. But then I have to make a solution where the user can associate their user id from Facebook to Aspnetzero's userid. I don't know how to debug Facebook authentication with localhost in my development environment. I also do not understand how to change code of aspnetzero core project to handles the authentication. It looks like this code is not open source. Do you have any advice on how I can solve this?

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

Yes, I have registered my user in AspNetZero with my email. And now I try to login with my Facebook profile with the same email address.

This is not supported actually.

Have you deleted your user on the UI or on the database ?

Hi @ismcagdas :) First I deleted it in UI, then I restored it in db and just changed my email address. After that I got this error: "There is no entity User with id = 85!". My latest userId is 84.

But if it is not supported then I don't understand how this is suppose to work? Do you think there's a lot of work to get it to work like this? When my user registrate a profile, I also store the the email as username. So if a user later wants to login with facebook, I need to use the email address to identify the user. I also wonder if you not support registering user with Facebook either, because in my solution no buttons are visible for this?

<cite>aaron: </cite> Email address must be unique.

Yes, I have registered my user in AspNetZero with my email. And now I try to login with my Facebook profile with the same email address. I can't find an option to create a user with Facebook. Only to login with existing user. And when I try to login with Facebook , I get an error that says that my email is already taken. It seems like the code tries to create an user instead of authenticating.

If I delete my user in aspnetzero and try to login with Facebook, i get an error: "There is no entity User with id = 85!"

I have done this:

  • Created an AppId and AppSecret and inserted this in AppSettings.Production
  • Filled in for every field in Basic Settings for Facebook App and inserted my domain address in the field "Valid OAuth Redirect URIs"
  • In Azure I have set App Service Authentication to On and inserted my domain in for Allowded Exernal Redirect Urls, and under Configuration Providers I have set Facebook to "Configured".
  • My code is also updated. At least the Asp.Net Core project and login.component.ts.

Have I forgotten something?

I get an error that says that my email is already taken.

<cite>aaron: </cite>

POST https**:**//votechawebhost.azurewebsites.net/api/TokenAuth/ExternalAuthenticate 500 (Internal Server Error)

Check the error in Logs.txt.

This is my log:

ERROR 2018-05-07 09:04:16,429 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - String reference not set to an instance of a String. Parameter name: s System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at Abp.Extensions.StringExtensions.ToMd5(String str) at GlobalOpinions.Web.Controllers.TokenAuthController.<RegisterExternalUserAsync>d__26.MoveNext() in D:\WordOfOpinions\www\Version2\GlobalOpinions\GlobalOpinions\aspnet-core\src\GlobalOpinions.Web.Core\Controllers\TokenAuthController.cs:line 350 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at GlobalOpinions.Web.Controllers.TokenAuthController.<ExternalAuthenticate>d__24.MoveNext() in D:\WordOfOpinions\www\Version2\GlobalOpinions\GlobalOpinions\aspnet-core\src\GlobalOpinions.Web.Core\Controllers\TokenAuthController.cs:line 282 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.<Execute>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext() INFO 2018-05-07 09:04:16,473 [4 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2018-05-07 09:04:16,480 [4 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) in 2548.1516ms INFO 2018-05-07 09:04:16,487 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 2588.3632ms 500 application/json; charset=utf-8 INFO 2018-05-07 09:04:24,381 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://votechawebhost.azurewebsites.net/api/TokenAuth/ExternalAuthenticate">http://votechawebhost.azurewebsites.net ... thenticate</a> 0 INFO 2018-05-07 09:04:24,382 [4 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 09:04:24,383 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 2.304ms 204 INFO 2018-05-07 09:04:24,433 [12 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST <a class="postlink" href="http://votechawebhost.azurewebsites.net/api/TokenAuth/ExternalAuthenticate">http://votechawebhost.azurewebsites.net ... thenticate</a> application/json 332 INFO 2018-05-07 09:04:24,435 [12 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 09:04:24,448 [12 ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "ExternalAuthenticate", controller = "TokenAuth", area = ""}. Executing action GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) INFO 2018-05-07 09:04:24,449 [12 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 09:04:24,487 [12 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) with arguments (GlobalOpinions.Web.Models.TokenAuth.ExternalAuthenticateModel) - Validation state: Valid ERROR 2018-05-07 09:04:25,249 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - String reference not set to an instance of a String. Parameter name: s System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at Abp.Extensions.StringExtensions.ToMd5(String str) at GlobalOpinions.Web.Controllers.TokenAuthController.<RegisterExternalUserAsync>d__26.MoveNext() in D:\WordOfOpinions\www\Version2\GlobalOpinions\GlobalOpinions\aspnet-core\src\GlobalOpinions.Web.Core\Controllers\TokenAuthController.cs:line 350 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at GlobalOpinions.Web.Controllers.TokenAuthController.<ExternalAuthenticate>d__24.MoveNext() in D:\WordOfOpinions\www\Version2\GlobalOpinions\GlobalOpinions\aspnet-core\src\GlobalOpinions.Web.Core\Controllers\TokenAuthController.cs:line 282 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.<Execute>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext() INFO 2018-05-07 09:04:25,279 [4 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2018-05-07 09:04:25,280 [4 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) in 830.7446ms INFO 2018-05-07 09:04:25,280 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 846.9981ms 500 application/json; charset=utf-8 INFO 2018-05-07 10:02:51,430 [19 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://votechawebhost.azurewebsites.net/api/TokenAuth/ExternalAuthenticate">http://votechawebhost.azurewebsites.net ... thenticate</a>
INFO 2018-05-07 10:02:51,432 [19 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 10:02:51,432 [19 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 2.3618ms 204 INFO 2018-05-07 10:03:36,243 [20 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST <a class="postlink" href="http://votechawebhost.azurewebsites.net/api/TokenAuth/ExternalAuthenticate">http://votechawebhost.azurewebsites.net ... thenticate</a> application/json 336 INFO 2018-05-07 10:03:36,246 [20 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 10:03:36,267 [20 ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "ExternalAuthenticate", controller = "TokenAuth", area = ""}. Executing action GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) INFO 2018-05-07 10:03:36,268 [20 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-07 10:03:36,310 [20 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method GlobalOpinions.Web.Controllers.TokenAuthController.ExternalAuthenticate (GlobalOpinions.Web.Core) with arguments (GlobalOpinions.Web.Models.TokenAuth.ExternalAuthenticateModel) - Validation state: Valid ERROR 2018-05-07 10:03:37,347 [20 ] Mvc.ExceptionHandling.AbpExceptionFilter - String reference not set to an instance of a String. Parameter name: s System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at Abp.Extensions.StringExtensions.ToMd5(String str) at GlobalOpinions.Web.Controllers.TokenAuthController.<RegisterExternalUserAsync>d__26.MoveNext() in D:\WordOfOpinions\www\Version2\GlobalOpinions\GlobalOpinions\aspnet-core\src\GlobalOpinions.Web.Core\Controllers\TokenAuthController.cs:line 350 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at GlobalOpinions.Web.Controllers.TokenAuthController.

Showing 21 to 30 of 98 entries