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

Activities of "mahendra"

Answer

This has been fixed....please don't bother

Answer

Not getting any error in Server's log.txt file

Answer

Thought, you may want to see the startup.cs file.

public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //MVC
            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
            }).AddNewtonsoftJson();

            
            services.AddSignalR(options => { options.EnableDetailedErrors = true; });


            //Azure:SignalR:ConnectionString is the default configuration key that SignalR looks for to establish a connection.
            //services.AddSignalR().AddAzureSignalR(@"Endpoint=https://ivendwebsignalr.service.signalr.net;AccessKey=+oTw1tBp2lEbDpJ2e/Pyl3LKreDfqQfvNEemaOPFOmo=;Version=1.0;");


            //Configure CORS for angular2 UI
            services.AddCors(options =>
            {
                options.AddPolicy(DefaultCorsPolicyName, builder =>
                {
                    //App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
                    builder
                        .WithOrigins(
                            // App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
                            _appConfiguration["App:CorsOrigins"]
                                .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                .Select(o => o.RemovePostFix("/"))
                                .ToArray()
                        )
                        .SetIsOriginAllowedToAllowWildcardSubdomains()
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials();
                });
            });

            IdentityRegistrar.Register(services);
            AuthConfigurer.Configure(services, _appConfiguration);

            //Identity server
            if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
            {
                IdentityServerRegistrar.Register(services, _appConfiguration, options =>
                     options.UserInteraction = new UserInteractionOptions()
                     {
                         LoginUrl = "/UI/Login",
                         LogoutUrl = "/UI/LogOut",
                         ErrorUrl = "/Error"
                     });
            }

            if (WebConsts.SwaggerUiEnabled)
            {
                //Swagger - Enable this line and the related lines in Configure method to enable swagger UI
                services.AddSwaggerGen(options =>
                {
                    options.SwaggerDoc("v1", new OpenApiInfo() { Title = "iVend API", Version = "v1" });
                    options.DocInclusionPredicate((docName, description) => true);
                    options.ParameterFilter<SwaggerEnumParameterFilter>();
                    options.SchemaFilter<SwaggerEnumSchemaFilter>();
                    options.OperationFilter<SwaggerOperationIdFilter>();
                    options.OperationFilter<SwaggerOperationFilter>();
                    options.CustomDefaultSchemaIdSelector();
                });
            }

            //Recaptcha
            services.AddRecaptcha(new RecaptchaOptions
            {
                SiteKey = _appConfiguration["Recaptcha:SiteKey"],
                SecretKey = _appConfiguration["Recaptcha:SecretKey"]
            });

            //if (WebConsts.HangfireDashboardEnabled)
            //{
            //    //Hangfire(Enable to use Hangfire instead of default job manager)
            //    services.AddHangfire(config =>
            //    {
            //        config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
            //    });
            //}

            if (WebConsts.GraphQL.Enabled)
            {
                services.AddAndConfigureGraphQL();
                services.AddSingleton<QueryContainer>();
            }

            if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
            {
                services.AddAbpZeroHealthCheck();

                var healthCheckUISection = _appConfiguration.GetSection("HealthChecks")?.GetSection("HealthChecksUI");

                if (bool.Parse(healthCheckUISection["HealthChecksUIEnabled"]))
                {
                    services.Configure<HealthChecksUISettings>(settings =>
                    {
                        healthCheckUISection.Bind(settings, c => c.BindNonPublicProperties = true);
                    });
                    services.AddHealthChecksUI();
                }
            }

            //Configure Abp and Dependency Injection
            return services.AddAbp<iVendWebHostModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility<LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                );

                options.PlugInSources.AddFolder(Path.Combine(_hostingEnvironment.WebRootPath, "Plugins"), SearchOption.AllDirectories);
            });
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {

            Clock.Provider = ClockProviders.Utc;
            
            
            //Initializes ABP framework.
            app.UseAbp(options =>
            {
                options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();
            app.UseRouting();

            app.UseCors(DefaultCorsPolicyName); //Enable CORS!

            app.UseAuthentication();
            //app.UseAuthorization();
            app.UseJwtTokenMiddleware();

            if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
            {
                //app.UseJwtTokenMiddleware("IdentityBearer");
                app.UseIdentityServer();
            }

            app.UseAuthorization();

            using (var scope = app.ApplicationServices.CreateScope())
            {
                if (scope.ServiceProvider.GetService<DatabaseCheckHelper>().Exist(_appConfiguration["ConnectionStrings:Default"]))
                {
                    app.UseAbpRequestLocalization();
                }
            }

            //if (WebConsts.HangfireDashboardEnabled)
            //{
            //    //Hangfire dashboard &server(Enable to use Hangfire instead of default job manager)
            //    app.UseHangfireDashboard(WebConsts.HangfireDashboardEndPoint, new DashboardOptions
            //    {
            //        Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
            //    });
            //    app.UseHangfireServer();
            //}

            if (bool.Parse(_appConfiguration["Payment:Stripe:IsActive"]))
            {
                StripeConfiguration.ApiKey = _appConfiguration["Payment:Stripe:SecretKey"];
            }

            if (WebConsts.GraphQL.Enabled)
            {
                app.UseGraphQL<MainSchema>();
                if (WebConsts.GraphQL.PlaygroundEnabled)
                {
                    app.UseGraphQLPlayground(
                        new GraphQLPlaygroundOptions()); //to explorer API navigate https://*DOMAIN*/ui/playground
                }
            }

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub<AbpCommonHub>("/signalr");
                //endpoints.MapHub<ChatHub>("/signalr-chat");
                //endpoints.MapHub<IVendWebHub>("/ivendwebhub");

                endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");

                if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
                {
                    endpoints.MapHealthChecks("/healthz", new HealthCheckOptions()
                    {
                        Predicate = _ => true,
                        ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
                    });
                }
            });

            if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
            {
                if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksUI:HealthChecksUIEnabled"]))
                {
                    app.UseHealthChecksUI();
                }
            }

            if (WebConsts.SwaggerUiEnabled)
            {
                // Enable middleware to serve generated Swagger as a JSON endpoint
                app.UseSwagger();
                // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
                
                app.UseSwaggerUI(options =>
                {
                    options.SwaggerEndpoint(_appConfiguration["App:SwaggerEndPoint"], "Tagrain API V1");
                    options.IndexStream = () => Assembly.GetExecutingAssembly()
                        .GetManifestResourceStream("CitiXsys.iVend.Web.wwwroot.swagger.ui.index.html");
                    options.InjectBaseUrl(_appConfiguration["App:ServerRootAddress"]);
                }); //URL: /swagger
            }
        }
Answer

I revert the Azure's CORS policy back. see the screen shot below. Earlier Enable Access-Control-Allow-Credentials was ticked.

Below is the setting of AZPNetZero's CORS.

Now when we browse the site then after login we get the CORS error. Please see below screen shot. This error was not coming till the time we had not enabled the signalR.

Question

Hi Support,

We have a multitenant application deployed in Azure. Both backend and frontend are deployed on the same AppService but on different slots. We have setup the CorsOrigins settings as "https://*.tagrain.net" in the AppService Configuration of the backend and all is good till here.

The moment we started the feature of signalR, and browse the site (say abc.tagrain.net), we started getting the following error after login page.

Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. Error: Failed to complete negotiation with the server: Error Error: Failed to start the connection: Error

While googling we came across to the below link that talks about CORS setting in Azure App. https://support.aspnetzero.com/QA/Questions/7574/Chat-not-connecting-after-deploying-to-Azure

We followed this link and tick the check box "Enable Access-Control-Allow-Credentials" and removed the * from the Allowed Origins

Now when we browse the site (abc.tagrain.net), we did not get the error of 'Access-Control-Allow-Credentials'.....we thought all is good now.

But now when we browse the site tagrain.net (I mean without tenancyName prefix), we are getting the below error:

Access to XMLHttpRequest at 'https://tagrainretail-prodserver.azurewebsites.net//AbpUserConfiguration/GetAll?d=1601442505849' from origin 'https://abintest15.tagrain.net' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

polyfills.df90ed90577f0abf84f8.js:1 GET https://tagrainretail-prodserver.azurewebsites.net//AbpUserConfiguration/GetAll?d=1601442505849 net::ERR_FAILED

Please help....

Regards, Mahendra

Thanks....much appreciated....

Hi Expert,

I have added the singleton dependency see the bold line below and I get the optimum performance now. Is the following changes ok? Please confirm.

if (WebConsts.GraphQL.Enabled) { services.AddAndConfigureGraphQL(); services.AddSingleton<QueryContainer>(); }

Hi,

Just to let you know, below is my QueryContainer class. I have many GraphQL queries inside it. If I comment all and leave one (the one I'll query) say if I leave "ProductQuery productQuery" uncommented and comment the rest, then it works fast. But if I have all the below queries uncommented then, it becomes slow.

Any hint would be appreciated.. Regards, Mahendra

using Abp.Dependency; using GraphQL.Types;

namespace CitiXsys.iVend.Queries.Container { public sealed class QueryContainer : ObjectGraphType, ITransientDependency { public QueryContainer(RoleQuery roleQuery, UserQuery userQuery, OrganizationUnitQuery organizationUnitQuery, AuditLogQuery auditLogQuery, ProductQuery productQuery, TeamQuery teamQuery, VendorGroupQuery vendorGroupQuery, RetailProfileQuery retailProfileQuery, FulfillmentQuery fulfillmentQuery, SurchargeQuery surchargeQuery, WarehouseQuery warehouseQuery, ManufacturerQuery manufacturerQuery, CountryQuery countryQuery, BankQuery bankQuery, DepartmentQuery departmentQuery, JobCodeQuery jobCodeQuery, ReasonCodeQuery reasonCodeQuery, BarCodeMaskQuery barCodeMaskQuery, ShippingTypeQuery shippingTypeQuery, ProductGroupQuery productGroupQuery, RetailEventQuery retailEventQuery, RetailMessageQuery retailMessageQuery, POSQuery cashRegisterQuery, CurrencyQuery currencyQuery, CustomerQuery customerQuery, CustomerGroupQuery customerGroupQuery, ExpenseQuery expenseQuery, TaxEventQuery taxEventQuery, ValidationRuleQuery validationRuleQuery, PriceConditionQuery priceConditionQuery, VendorQuery vendorQuery, TaxGroupQuery productClassQuery, PurchaseOrderQuery purchaseOrderQuery, GoodsReceiptQuery goodsReceiptQuery, GoodsIssueQuery goodsIssueQuery, SaleAttributeQuery saleAttributeQuery, StockTransferQuery stockTransferQuery, StateQuery stateQuery, LineAttributeQuery lineAttributeQuery, LoyaltySetupQuery loyaltySetupQuery, LayawayPlanQuery layawayPlanQuery, InventoryCycleSetupQuery inventoryCycleSetupQuery, StockTransferRequestQuery stockTransferRequestQuery, SecurityUserQuery securityUserQuery, ProductCategoryQuery productCategoryQuery, LoyaltyLevelQuery loyaltyLevelQuery, PaymentTypeQuery paymentTypeQuery, TaxJurisdictionQuery taxJurisdictionQuery, TaxAreaQuery taxAreaQuery, TaxConditionQuery taxConditionQuery, TillMasterQuery tillMasterQuery, TillQuery tillQuery, RegisteredApplicationQuery registeredApplicationQuery, GiftCertificateQuery giftCertificateQuery, GiftCertificateManagementQuery giftCertificateManagementQuery, MerchandiseHierarchyDetailQuery merchandiseHierarchyDetailQuery, CouponQuery couponQuery, RetailTransactionQuery retailTransactionQuery, SalesTargetQuery salesTargetQuery, PrintFormatQuery printFormatQuery, InventoryReportQuery inventoryReportQuery, SecurityRoleQuery securityRoleQuery,
TenderCollectionReportQuery tenderCollectionReportQuery, InventoryMovementReportQuery inventoryMovementReportQuery, TaxCollectionReportQuery taxCollectionReportQuery, TaxPayableReportQuery taxPayableReportQuery, SalesTargetReportQuery salesTargetReportQuery, TaxCodeQuery taxCodeQuery, SalesReportQuery salesReportQuery, CustomerReportQuery customerReportQuery

                        )
    {
        AddField(roleQuery.GetFieldType());
        AddField(organizationUnitQuery.GetFieldType());
        AddField(userQuery.GetFieldType());
        AddField(auditLogQuery.GetFieldType());
         AddField(productQuery.GetFieldType());
        AddField(teamQuery.GetFieldType());
        AddField(vendorGroupQuery.GetFieldType());
        AddField(retailProfileQuery.GetFieldType());
        AddField(fulfillmentQuery.GetFieldType());
        AddField(surchargeQuery.GetFieldType());
        AddField(warehouseQuery.GetFieldType());
        AddField(manufacturerQuery.GetFieldType());
        AddField(countryQuery.GetFieldType());
        AddField(bankQuery.GetFieldType());
        AddField(departmentQuery.GetFieldType());
        AddField(jobCodeQuery.GetFieldType());
        AddField(reasonCodeQuery.GetFieldType());
        AddField(barCodeMaskQuery.GetFieldType());
        AddField(shippingTypeQuery.GetFieldType());
        AddField(productGroupQuery.GetFieldType());
        AddField(retailEventQuery.GetFieldType());
        AddField(retailMessageQuery.GetFieldType());
        AddField(cashRegisterQuery.GetFieldType());
        AddField(currencyQuery.GetFieldType());
        AddField(customerQuery.GetFieldType());
        AddField(customerGroupQuery.GetFieldType());
        AddField(expenseQuery.GetFieldType());
        AddField(taxEventQuery.GetFieldType());
        AddField(validationRuleQuery.GetFieldType());
        AddField(priceConditionQuery.GetFieldType());
        AddField(productClassQuery.GetFieldType());
        AddField(vendorQuery.GetFieldType());
        AddField(purchaseOrderQuery.GetFieldType());
        AddField(saleAttributeQuery.GetFieldType());
        AddField(lineAttributeQuery.GetFieldType()); 
        AddField(inventoryCycleSetupQuery.GetFieldType());
        AddField(goodsReceiptQuery.GetFieldType());
        AddField(stockTransferQuery.GetFieldType());
        AddField(stateQuery.GetFieldType());
        AddField(goodsIssueQuery.GetFieldType());
        AddField(loyaltySetupQuery.GetFieldType());
        AddField(layawayPlanQuery.GetFieldType());
        AddField(stockTransferRequestQuery.GetFieldType());
        AddField(securityUserQuery.GetFieldType());
        AddField(productCategoryQuery.GetFieldType());
        AddField(loyaltyLevelQuery.GetFieldType());
        AddField(paymentTypeQuery.GetFieldType());
        AddField(taxJurisdictionQuery.GetFieldType());
        AddField(taxAreaQuery.GetFieldType());
        AddField(taxConditionQuery.GetFieldType());
        AddField(tillMasterQuery.GetFieldType());
        AddField(tillQuery.GetFieldType());
        AddField(registeredApplicationQuery.GetFieldType());
        AddField(giftCertificateQuery.GetFieldType());
        AddField(giftCertificateManagementQuery.GetFieldType());
        AddField(merchandiseHierarchyDetailQuery.GetFieldType());
        AddField(couponQuery.GetFieldType());
        AddField(retailTransactionQuery.GetFieldType());
        AddField(salesTargetQuery.GetFieldType());
        AddField(printFormatQuery.GetFieldType());
        AddField(inventoryReportQuery.GetFieldType());
        AddField(securityRoleQuery.GetFieldType());
        AddField(tenderCollectionReportQuery.GetFieldType());
        AddField(inventoryMovementReportQuery.GetFieldType());
        AddField(taxCollectionReportQuery.GetFieldType());
        AddField(taxPayableReportQuery.GetFieldType());
        AddField(salesTargetReportQuery.GetFieldType());
        AddField(taxCodeQuery.GetFieldType());
        AddField(salesReportQuery.GetFieldType());
        AddField(customerReportQuery.GetFieldType());
    }
}

}

Hi Team,

I would like to take this opportunity to explain the business case again.

We have created a custom entity "Business Partner" via asp.net zero power tool and attached one or more abpuser(s) to this business partner.

Our requirement is if we delete this "Business partner" record from the WebGUI then behind the sceen through service API we would like to delete all attached abp user(s) assigned to this business partner including the one with which user is currently logged in.

So once all abp user(s) are deleted, we have to logout the current user and need to return to login page.

Now please let us know what code we need to write to delete, logout current user and list of user(s) we have and then will return to login page.

This current user needs to deleted behind the sceen through service api, not on controller apis or direct through Angular Api.

We are open to have webex session with you. Please let us know the email id where invite can be send.

Hi,

The Resolve function of graphQL query takes long to hit. For example if I run below query from GraphQL playground, it taks almost 4 seconds to hit the breakpoint put on the first line of Resolve function in UserQuery.cs file. First execution of query, I can understand it might be taking some time as the GrpahQL engine might be instantiating. But for subsequent query as well it takes considerable amount of time (almost 4 seconds) to hit the first line of the Resolve function of UserQuery.cs file.

`query getAll { users{ items{ id name surname }

} }`

Any indea to boost this performance would be of great help.

Regards, Mahendra

Showing 111 to 120 of 203 entries