Base solution for your next web application

Activities of "carelearning"

Dear @ismcagdas ,

We were able to narrow down the error to the IAbpZeroDbMigrator.CreateOrMigrateForHost(); call.

However we were able to get the new tooling working by replacing migrate with ef6 with the following code.

EF 6.2.0 (old)
migrate.exe "MyCompanyName.AbpZeroTemplate.EntityFramework.dll" /StartUpDirectory=.\ MyCompanyName.AbpZeroTemplate.AbpZeroTemplateHost.Configuration /startupConfigurationFile="../web.config"
EF 6.3.0+ (new)
ef6.exe database update --assembly "MyCompanyName.AbpZeroTemplate.EntityFramework.dll" --migrations-config "MyCompanyName.AbpZeroTemplate.AbpZeroTemplateHost.Configuration" --config "../web.config"

Thank you for your time and energy.

Dear @Aaron,

Thanks. We were able to apply the workaround with the following code:

WebClientInfoProviderHack.cs

namespace MyCompanyName.AbpZeroTemplate.Web.Hacks
{
    using Abp.Auditing;
    using System;
    using System.Net;
    using System.Net.Sockets;
    using System.Web;

    public class WebClientInfoProviderHack : WebClientInfoProvider
    {
        protected override string GetClientIpAddress()
        {
            var httpContext = HttpContext.Current;
            if (httpContext?.Request.ServerVariables == null)
                return null;

            var clientIp = httpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ??
                           httpContext.Request.ServerVariables["REMOTE_ADDR"];

            // Remove port if present
            clientIp = clientIp.Contains(":") ? clientIp.Remove(clientIp.IndexOf(':')) : clientIp;

            try
            {
                foreach (var hostAddress in Dns.GetHostAddresses(clientIp))
                    if (hostAddress.AddressFamily == AddressFamily.InterNetwork)
                        return hostAddress.ToString();

                foreach (var hostAddress in Dns.GetHostAddresses(Dns.GetHostName()))
                    if (hostAddress.AddressFamily == AddressFamily.InterNetwork)
                        return hostAddress.ToString();
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.ToString());
            }

            return clientIp;
        }

    }
}

AbpZeroTemplateWebModule.cs

public override void PreInitialize()
        {
            // elided code here
            Configuration.ReplaceService<IClientInfoProvider, WebClientInfoProviderHack>();
        }

Hello Volosoft Representatives, After upgrading to Abp 5.1 we were able to get our project to run in Visual Studio. However, when we published to IIS we got the following error:

Which was from the following code block in Global.asax.cs:

        private void RestoreUserLanguage()
        {
            var settingManager = AbpBootstrapper.IocManager.Resolve<ISettingManager>();
            var defaultLanguage = settingManager.GetSettingValue(LocalizationSettingNames.DefaultLanguage);

            if (defaultLanguage.IsNullOrEmpty())
            {
                return;
            }

            try
            {
                CultureInfo.GetCultureInfo(defaultLanguage);
                Response.Cookies.Add(new HttpCookie("Abp.Localization.CultureName", defaultLanguage) { Expires = Clock.Now.AddYears(2) });
            }
            catch (CultureNotFoundException exception)
            {
                LogHelper.Logger.Warn(exception.Message, exception);
            }
        }
        

We were able to reproduce this without making any customizations other than changing the connection string by cloning from aspnet-zero on the latest dev branch, we ran update-database -verbose and then published to IIS.

Is there anyway to resolve this?

Dear @ismcagdas

We were migrating from this commit be0fc34b5c270a9743a9ad830ebed0f5e4dc24ba which is targeting Abp 4.11.0. Is this information you need?

Hello Volosoft Representatives,

We are pulling the latest updates (ABP 5.1) into our project. This requires an update from EF 6.2.0 to EF 6.4.0. When we run update-database we get this error:

System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid object name 'dbo.AbpTenants'.
  

We are using the "Single deployment/hybrid databases" approach as explained here: https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy#single-deployment-hybrid-databases. Our tenant databases do not have an abptenants table. The schema migrates and then we get an error during seeding. How can we investigate this error? We commented out the seed method seen here . Any information would be appreciated.

Dear Abp Represenative,

We encountered an issue while upgrading Abp NuGet packages from 4.9.0 to 4.10.0.

We are using the "ASP.NET MVC 5.x, Web API and AngularJS 1.x based Single-Page Application (SPA) solution."

After calling SaveChangesAsync on the CurrentUnitOfWork we get a "Value cannot be null Parameter name: source" exception (please reference included screenshot).

Here is the stack trace:

at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
 at Abp.EntityHistory.EntityHistoryHelper.GetRelationshipChanges(DbEntityEntry entityEntry, EntityType entityType, EntitySet entitySet, ICollection`1 relationshipChanges, Boolean auditedPropertiesOnly)
 at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeSet(DbContext context)
 at Abp.Zero.EntityFramework.AbpZeroCommonDbContext`2.<SaveChangesAsync>d__104.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Abp.EntityFramework.Uow.EfUnitOfWork.<SaveChangesInDbContextAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Abp.EntityFramework.Uow.EfUnitOfWork.<SaveChangesAsync>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.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
 at MyCompanyName.AbpZeroTemplate.Enrollment.EnrollmentAppService.<AddUserAsync>d__63.MoveNext() in c:\projects\port\src\careLearning\MyCompanyName.AbpZeroTemplate.Application\Enrollment\EnrollmentAppService.cs:line 934

Our work around is to disable the EntityHistory feature outlined here https://aspnetboilerplate.com/Pages/Documents/Entity-History.

This is a FYI for anyone else who may experience the issue.

Dear Support, It has been 9 days since we have last heard from you. We added our stack information when requested and was just checking in to see if there is any update on this or if anymore information is needed. Thank you,

Dear Support,

We are using the legacy MVC 5 version. In the Account controller and Login action we would like to run a SQL query (ClearUserLocksAsync) against a custom entity when an user logins in. However this returns the "The user could not login" error. We can wrap it in Try/Catch and ignore the exception. But we would like to explore if there is a better alternative.

Account->Login
      [HttpPost]
      [UnitOfWork]
      public virtual async Task&lt;JsonResult&gt; Login(LoginViewModel loginModel, string returnUrl = "", string returnUrlHash = "")
      {
          // ... unmodified
          await UnitOfWorkManager.Current.SaveChangesAsync();

          // Custom call
          await _accessAppService.ClearUserLocksAsync(loginResult.User.Id);

          return Json(new AjaxResponse { TargetUrl = returnUrl });
      }
    }
    

AccessService->ClearUserLocksAsync

     public async Task ClearUserLocksAsync(long id)
    {
        var userLocks = await _lockRepository
            .GetAll()
            .Where(x => x.UserId == id)
            .ToListAsync();

        foreach (var userLock in userLocks)
            await _lockRepository.DeleteAsync(userLock);
    }
    

Error

Current user did not login to the application!

Stack Trace

Abp.Authorization.AbpAuthorizationException: Current user did not login to the application! at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.AuthorizationHelper.<CheckPermissions>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func`1 action) at Abp.Authorization.AuthorizationHelperExtensions.Authorize(IAuthorizationHelper authorizationHelper, MethodInfo methodInfo, Type type) at Abp.Authorization.AuthorizationInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Auditing.AuditingInterceptor.PerformAsyncAuditing(IInvocation invocation, AuditInfo auditInfo) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.AccessAppServiceProxy.ClearUserLocksAsync(Int64 id) at MyCompanyName.AbpZeroTemplate.Web.Controllers.AccountController.

Hello,

We have a project with several hundred tenants. What advice would you give to allow us to separate the communication between tenants? Currently, we send a "lock" message and all users receive this message regardless of tenancy. Options might include:

  • Give each tenant a separate endpoint, aka hub
  • Use signalR's group feature and assign each tenant an unique group name

We also plan to put our webservers behind a load balancer. Looking at the documentation (here), Redis is how you scale-out. Therefore the solution we are looking for needs to scale too.

Thank you for your time.

Thank you.

Showing 11 to 20 of 108 entries