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

Activities of "rickfrankel"

You need to override the GetClientIpAddress in the HttpContextClientInfoProvider.

What I've done is have in the MyProject.Web.Core project in the Helpers folder I created my own class.

`using Abp.AspNetCore.Mvc.Auditing; using Microsoft.AspNetCore.Http; using System;

namespace MyProject.Web.Helpers { public class MyProjectHttpContextClientInfoProvider : HttpContextClientInfoProvider { private readonly IHttpContextAccessor _httpContextAccessor;

    public MyProjectHttpContextClientInfoProvider(IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;

    }

    protected override string GetClientIpAddress()
    {
        try
        {
            var httpContext = _httpContextAccessor.HttpContext;

            if (httpContext?.Request?.Headers?.ContainsKey("Cf-Connecting-IP") ?? false)
            {
                return httpContext.Request.Headers["Cf-Connecting-IP"];
            }
            else
            {
                return httpContext?.Connection?.RemoteIpAddress?.ToString();
            }

        }
        catch (Exception ex)
        {
            Logger.Warn(ex.ToString());
        }
        return null;
    }
}

} `

Then you need to tell the system to use your class.

In the MyProjectWebCoreModule.cs file in the same project.

Add this line at the end of PreInitialize

`Configuration.ReplaceService<IClientInfoProvider, MyProjectHttpContextClientInfoProvider>(DependencyLifeStyle.Transient);

I have found the problem. It is this line. https://github.com/aspnetzero/aspnet-zero-core/blob/577684256e8e1a4cf58c886f820f9061d42020d5/angular/src/app/shared/layout/nav/side-bar-menu.component.ts#L151

Changed it to this and it works fine.

    if (!this.iconMenu && this.isMenuItemIsActive(item)) {
        classes += ' show';
    }
    
    

Removed the parentItem==null check as that was stopping it from adding the show class to a nested sub-menu.

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version?
  • 11.2.1
  • What is your product type (Angular or MVC)?
  • Angular
  • What is product framework type (.net framework or .net core)?
  • .Net Core

If issue related with ABP Framework

  • What is ABP Framework version?

If issue is about UI

  • Which theme are you using?
  • Default
  • What are the theme settings?
  • Default

In the standard template solution, I replaced the normal WebhookSubscription menu with this, in app-navigation.service.ts

                new AppMenuItem('Parent Menu', '', 'flaticon-interface-8', '', [], [
                    new AppMenuItem(
                        'WebhookSubscriptions',
                        'Pages.Administration.WebhookSubscription',
                        'flaticon2-world',
                        '/app/admin/webhook-subscriptions'
                    )
                ]),

<br> When you click on this menu item the Parent Menu collapses and you don't see which menu item is selected.  This doesn't happen if the nesting is only 1 level deep.

I'm wondering if it was broken with this fix https://support.aspnetzero.com/QA/Questions/10926/Side-bar-navigation---not-collapsing

It was working in v10

Interesting. Ok I think you are correct after all with your first response.

Putting in a ToList does work. However in my full application it doesn't.

In my full application the ToList doesn't work. However I think there is a lot more complexity in my Linq to SQL in my application which is triggering the issue. In the simple application as shown above the ToList does work.

Very strange. Thankfully I've only used it in a few places so have managed to work around the issue. Thanks for pointing me to it.

Cheers

if that were true then i would expect ToList to fix the problem as per that article, however it does not. i still get a problem.

i think the issue is more related to connection or unit of work management and it somehow being closed early.

Rick

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version?
  • 11.1.2
  • What is your product type (Angular or MVC)?
  • Angular
  • What is product framework type (.net framework or .net core)?
  • .Net Core

If issue related with ABP Framework

  • What is ABP Framework version?
  • 7.3

Related potentially to this ticket but thought I'd create a new one. https://support.aspnetzero.com/QA/Questions/10816/MvcAuthorizationAbpAuthorizationFilter---UnitOfWork-error

When you have code that makes a call to an IRepository from within a Select on an IQueryable (or an IEnumerable, if you call ToList() before the Select it doesn't make a difference) you get the below error when using MySQL as your DB.

ERROR 2022-06-27 11:01:23,556 [81 ] Mvc.ExceptionHandling.AbpExceptionFilter - Value cannot be null. (Parameter 'unitOfWork') System.ArgumentNullException: Value cannot be null. (Parameter 'unitOfWork') at Abp.EntityFrameworkCore.Uow.UnitOfWorkExtensions.GetDbContext[TDbContext](IActiveUnitOfWork unitOfWork, Nullable1 multiTenancySide, String name) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetDbQueryTable() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetQueryable() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetAllIncluding(Expression1[] propertySelectors) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetAll() at Abp.Domain.Repositories.AbpRepositoryBase2.FirstOrDefault(TPrimaryKey id) at Abp.Domain.Repositories.AbpRepositoryBase2.Get(TPrimaryKey id) at Inbound.Operations.BookingAttachmentAppService.<>c__DisplayClass6_0.b__13(BinaryObject _) in C:\Source\Inbound\aspnet-core\src\Inbound.Application\Operations\BookingAttachmentAppService.cs:line 109

at System.Linq.Enumerable.SelectListIterator`2.MoveNext() at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) at Abp.Auditing.JsonNetAuditSerializer.Serialize(Object obj) at Abp.AspNetCore.Mvc.Auditing.AbpAuditActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)


As per the other ticket when using the vanilla setup using MSSQL you get the below exception

ERROR 2022-06-23 17:11:17,525 [37 ] Mvc.ExceptionHandling.AbpExceptionFilter - There is already an open DataReader associated with this Connection which must be closed first. System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first. at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) at Microsoft.Data.SqlClient.SqlCommand.ValidateCommand(Boolean isAsync, String method) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.InitializeReader(Enumerator enumerator) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable1 source, Boolean& found) at lambda_method2167(Closure , QueryContext ) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate) at Abp.Domain.Repositories.AbpRepositoryBase2.FirstOrDefault(TPrimaryKey id) at lambda_method2163(Closure , QueryContext , DbDataReader , ResultContext , SingleQueryResultCoordinator ) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Inbound.Authorization.Users.UserAppService.GetUsers(GetUsersInput input) in C:\Source\Inbound-v11-2\aspnet-core\src\Inbound.Application\Authorization\Users\UserAppService.cs:line 124 at lambda_method2062(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

To reproduce all I did was take a newly downloaded vanilla setup and change the following default app service. You will see on the call to populate the property Fred in the select an exception is thrown. This did not happen in my previous version which was 10.2.

    [HttpPost]
    public async Task<PagedResultDto<UserListDto>> GetUsers(GetUsersInput input)
    {
        var query = GetUsersFilteredQuery(input);

        var userCount = await query.CountAsync();

        var users = await query
            .OrderBy(input.Sorting)
            .PageBy(input)
            .ToListAsync();

        var userListDtos = ObjectMapper.Map<List<UserListDto>>(users);
        await FillRoleNames(userListDtos);

        var roles = _userRoleRepository.GetAll();

        var test = await roles.Select(_ => new
        {
            Fred = _roleRepository.FirstOrDefault(_.RoleId)
        }).ToListAsync();


        return new PagedResultDto<UserListDto>(
            userCount,
            userListDtos
        );
    }

I think I've reproduced this in a slightly different way with a different exception.

I downloaded a completely clean version of 11.2.

And adjusted the GetUsers API call in the following way.

    [HttpPost]
    public async Task&lt;PagedResultDto&lt;UserListDto&gt;> GetUsers(GetUsersInput input)
    {
        var query = GetUsersFilteredQuery(input);

        var userCount = await query.CountAsync();

        var users = await query
            .OrderBy(input.Sorting)
            .PageBy(input)
            .ToListAsync();

        var userListDtos = ObjectMapper.Map&lt;List&lt;UserListDto&gt;>(users);
        await FillRoleNames(userListDtos);

        var roles = _userRoleRepository.GetAll();

        var test = await roles.Select(_ => new
        {
            Fred = _roleRepository.FirstOrDefault(_.RoleId)
        }).ToListAsync();


        return new PagedResultDto&lt;UserListDto&gt;(
            userCount,
            userListDtos
        );
    }

When you now run the vanilla solution and go to the users screen in the admin you get the following exception. It is a slightly different exception but that could be related to me using MySQL in my actual project, but in the vanilla solution I tried using MSSQL.

I also note an exception logged from the auditing (which I think is swallowed anyway) due to me running locally and the IP address being ::1

Either way I can't see why the above code shouldn't work correctly and from what I can tell it did in previous versions.

Thanks

ERROR 2022-06-23 17:11:17,525 [37 ] Mvc.ExceptionHandling.AbpExceptionFilter - There is already an open DataReader associated with this Connection which must be closed first. System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first. at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) at Microsoft.Data.SqlClient.SqlCommand.ValidateCommand(Boolean isAsync, String method) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.InitializeReader(Enumerator enumerator) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable1 source, Boolean& found) at lambda_method2167(Closure , QueryContext ) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate) at Abp.Domain.Repositories.AbpRepositoryBase2.FirstOrDefault(TPrimaryKey id) at lambda_method2163(Closure , QueryContext , DbDataReader , ResultContext , SingleQueryResultCoordinator ) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Inbound.Authorization.Users.UserAppService.GetUsers(GetUsersInput input) in C:\Source\Inbound-v11-2\aspnet-core\src\Inbound.Application\Authorization\Users\UserAppService.cs:line 124 at lambda_method2062(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

Ok. Perhaps not related to that issue. I changed the AddApp() call to be false for the RemoveConventionalInterceptors and it still fails.

PS: When trying to debug AspBoilerplate I get this now and cannot load symbols. Skipping symbol server "https://symbols.nuget.org/download/symbols". This server requires a PDB Checksum, which is not present in the binary being debugged https://symbols.nuget.org/download/symbols: Symbols not found on symbol server.

I'm still trying to find the cause, but it definitely looks like the unit of work doesn't get created for some reason. Or the one it was using is closed before the repository has used it.

At a guess it is very likely related to this comment as well. https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6274

My AppService is a little different here.

I do a GetAll on a simple IRepository.

I take the result and call result.Select(_ => new OutputDto { Id = _.Id FieldSomethingElse = anotherRepository.FirstOrDefault(.AnotherFieldId).MyProp });

The call to _anotherRepository is failing due to it loosing the UnitOfWork for some reason. No Hangfire jobs or anything else like this should be causing it as it is reproducible everytime on this AppService.

Showing 71 to 80 of 128 entries