Base solution for your next web application

Activities of "dominici"

Hi @ismcagdas, I found a solution by myself

I created a dedicated interface for my custom application services and another interface for the app services provided by asp net zero template.

Then, in the MyAppWebCoreModule.cs I wrote:

            Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(MyAppApplicationModule).GetAssembly(), useConventionalHttpVerbs: true
                ).Where(type => typeof(IAspNetZeroBaseAppService).IsAssignableFrom(type));

            Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(MyAppApplicationModule).GetAssembly(), useConventionalHttpVerbs: false
                ).Where(type => typeof(IMyAppBaseAppService).IsAssignableFrom(type));

By this way I can force the HttpPost on all my custom services (as the very old version of AspNetZero) and at the same time I can maintain the conventional verbs for the Angular part included in the new Asp Net Zero template

I hope this helps

Br, Fabrizio

Hi m.aliozkaya, I'm going a little deep in analysis and, changing the parameter to useConventionalHttpVerbs = false, a lot of methods (starting from the boostrap phase) doesn't work on the angular application. Not only "some things may not work as expected"

You can check this document for more information. https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#application-services-as-controllers

I red many time the documentation and I also searched in the forum before asking but no side-effects it's mentioned changing this parameter.

Since AspNetZero is a paid product and support is part of the services, I would have expected a more precise, technical and detailed answer

Hi, thanks for suggestions, I've updated all the data using a simple code snippet .

Br, Fabrizio

After a deep investigation , I found the reason.

I have added on backend side this sserialization formatting rule

            // Improve -> set by default enum to string conversion in serialization
            services.AddControllers().AddJsonOptions(x =>
            {
                // serialize enums as strings in api responses (e.g. Role)
                x.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());

                // ignore omitted parameters on models to enable optional params (e.g. User update)
                //x.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
            });

So all the enum previously returned as numbers have become strings.

So, in the "change tenant" function code -> tenant-change-modal.component.ts

            .subscribe((result: IsTenantAvailableOutput) => {
                switch (result.state) {
                    case TenantAvailabilityState.Available:
                        abp.multiTenancy.setTenantIdCookie(result.tenantId);
                        this.close();
                        location.reload();
                        return;
                    case TenantAvailabilityState.InActive:
                        this.message.warn(this.l('TenantIsNotActive', this.tenancyName));
                        this.focusTenancyNameInput();
                        break;
                    case TenantAvailabilityState.NotFound: //NotFound
                        this.message.warn(this.l('ThereIsNoTenantDefinedWithName{0}', this.tenancyName));
                        this.focusTenancyNameInput();
                        break;
                }

This switch doesn't match any value and the button simply do nothing :-(

I'm sorry, it's my fault but I was unlucky to don't get an error.

Consider adding a default condition in this switch case in order to manage all unexpected values.

Have a nice day

Br, Fabrizio

Hi oguzhanagir, I tried both solutions but still not work.

The server side middleware has no effect.

The HTML Meta tag on the angular side incresed the number of errors

My considerations are:

  • I have tried with Chrome, Firefox and Edge. Same behaviour on all browser
  • I made no change on the downloaded angular code and the server side works great. I don't think it's related to code or to browsers, many users would have reported it

Could be something related to my VS Code? yarn version -> v1.22.10 node version -> v20.15.1 npm version -> v10.7.0

Is the api IsTenantAvailable response valid and complete?

Thanks for support.

Br, Fabrizio

Hi all, thanks for suggestions. I'm trying different solutions and I confirm that's not easy.

Obviously, if I will find a good approach (not a workaround), I will share my implementation with the community.

Br

To be honest I don't like so much the idea to use a real db, because is very convenient to use an in memory db. I think asp net zero is a very powerful framework but this is a big limitation in a moment in which geospatial data are used a lot. In all my projects I need to do geospatial query. So I hope you consider with high priority to change effort with an equivalent library that support DbGeography. I tried to change effort by myself but for me is very hard because I have not a deep knowledge of asp net zero.

So, let's try to summarize what are the possibilities at the state of the art of asp net zero, keeping in mind that I need DbGeography:

  • I cannot use the asp net zero core because DbGeography is not supported by entity framework core. So I must use asp net zero .net framework
  • I could use DbGeography and a real db for testing. In this case do I have only to set the connection string to the real db in AppTestBase class here
_hostDb = DbConnectionFactory.CreateTransient();

and everything work?

  • I could continue to use effort ignoring DbGeography type. By the way I did't received your test code. Can you send me it?

You say asp net zero 4.0 won't use Effort. What library it will use for in memory testing?

Thanks for your support Fabrizio Dominici

Hi, no, I commented each DbGeography type except TestPosition. Unfortunately I cannot share my project with you for company policy. Please can you share with me the project you tested that ignore the DbGeography type? (<a href="mailto:[email protected]">[email protected]</a>) I have version 3.3.0 of aspnetzero core angular with .NET Framework 4.6.1. By the way, I tried to download a new aspnetzero core angular project 3.3.0 to create a basic test project with only an entity with a DbGeography problem but now it seems full asp.net core. Is it right? And it seems there is not DbGeography in entity framework (core version). I have had a lot of problems trying to migrate from asp.net framework to asp.net core and also from visual studio 2015 to visual studio 2017.

Anyway, can you change Effort with another library? Because I need to test also geospatial queries. Can you change Effort with another library? This is the best thing for me and for each person that buy aspnetzero I think.

Thanks a lot Fabrizio Dominici

Hi. I have the same problem and I tried for a long time to bypass it without success. I know that it is an issue of Effort but now I really need help.

I would like to explore 2 different possibilities:

  • Use Effort but ignore DbGeography type. This seems possible reading the comment of jimmymain, but in aspnetzero I get the same exception. Below my code:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
	base.OnModelCreating(modelBuilder);
	modelBuilder.Entity<Report>().Ignore(_ => _.TestPosition);
}
  • Change the effort library with an equivalent one. I searched on the web and it seems Moq library do the same thing of effort (see [https://msdn.microsoft.com/en-us/library/dn314429(v=vs.113).aspx])). I tried to use Moq without success. The main problem is that I cannot understand how to get a db connection string as Effort do:
_hostDb = DbConnectionFactory.CreateTransient();

Moreover, Moq seems a little bit different than Effort. I will appreciate suggestions and code snippet to configure Moq or another in-memory db library

Can you help me?

Thanks Fabrizio Dominici

Showing 1 to 9 of 9 entries