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

Activities of "collexe"

Prerequisites

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

We encounter issues when dealing with the framework on ASP.NET Core + Angular and IdentityServer Here’s the draft of the scenario on (1 Webhost API, and 2 clients) where the solution was acquired from AspNetZero. SSO Access Portal:

  1. Centralize portal of user management, role & permission management, managing edition & customer subscription.
  2. Database 1 using ABP schema.
  3. Web.Host API = localhost:44301
  4. Angular Client = localhost:4200

Customer End / Client Access:

  1. Another hosted client for customer transactions.
  2. Database 2 using Custom Schema with ABPUsers.Id as the transaction references
  3. Web.Host API = localhost:44302
  4. Angular Client = localhost:4300

As per AspNetZero documentation of Identity Server for ASP.NET Core + Angular solution: https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Infrastructure-Core-Angular-Identity-Server4-Integration We can set the Web.Host as an IdentityServer which also supports OpenID as social login https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Features-Angular-Social-Logins

Here’s our setup for localhost: 44301 : AppSettings.Json

When top up this 2 line code too at localhost:44301 Web.Host\StartUp\AuthConfigurer.cs Here’s the setup details for localhost:44302 : AppSettings.Json And Here’s another config for localhost:4300 at login.service.ts. and remoteSeviceBaseURL set to localhost:44302 at appconfig.json Below is the result we get.

  1. From localhost:4300 login with OpenID, URL redirected to localhost:4200 with this generated URL http://localhost:4200/account/login?response_type=id_token%20token&client_id=custclient&state=MWE2azM3RExoYWZxanBRSWx0VnREUGxmMTk1Z2hnbUdRUDN-SjV4TUVnWGx5%3BopenIdConnect%253D1&redirect_uri=http%3A%2F%2Flocalhost%3A4300%2Faccount%2Flogin&scope=openid%20profile%20email%20default-api&nonce=MWE2azM3RExoYWZxanBRSWx0VnREUGxmMTk1Z2hnbUdRUDN-SjV4TUVnWGx5
  2. After successful login it did not redirect back to localhost:4300
  3. Localhost:4200 has AccessToken value at cookies
  4. Manually redirect to Localhost:4300 and it already login thru the app, but not having AccessToken at cookies. Soon received exceptions at localhost:44302 that AccessToken is null when try to read access token from cookies.

In the second attempt, we follow the step mentioned for ASP.NET Core + angular documentation https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Infrastructure-Core-Angular-Identity-Server4-Integration by changing the Login URL on the OpenID config at localhost:44302 to: and returned this generated URL which is having the same URL param as the previous one https://localhost:44301/UI/Login?response_type=id_token%20token&client_id=custclient&state=MUZ6LnhFZUphcjJMLVVBeWxsWk9UaG9LSW5URmlQNTNUZXBORFh3cmdhRjNI%3BopenIdConnect%253D1&redirect_uri=http%3A%2F%2Flocalhost%3A4300%2Faccount%2Flogin&scope=openid%20profile%20email%20default-api&nonce=MUZ6LnhFZUphcjJMLVVBeWxsWk9UaG9LSW5URmlQNTNUZXBORFh3cmdhRjNI But having the same output, which after successful login the page stays at localhost:44301 and not returned to localhost:4300 to triggers the OpenId callback.

While with the MVC client sample we manage to get the access token after login with https://localhost:44301/UI/Login page. and here’s the redirect URL generated from the MVC client sample: https://localhost:44301/UI/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Datnclient%26redirect_uri%3Dhttps%253A%252F%252Flocalhost%253A7002%252Fsignin-oidc%26response_type%3Dcode%26scope%3Ddefault-api%2520openid%2520profile%2520email%2520offline_access%26response_mode%3Dform_post%26nonce%3D637626478879962555.OTQ4ZjUxYWMtNjU4MC00N2IzLTgzOTEtODYwNDdiOTkyZDlhNjBkZmRkM2QtNDljYy00N2JlLThiZTYtOTBlNDg3Y2Y3MDE2%26state%3DCfDJ8LjpsvQIPopBleTfM5mDVEET_4L_K5liABk8FxhNffyECDWrkG8totdkqsZK9dcqeW7P2WKOCVWMwXBExoU1p8C96SBNw9a2QdALGPl6B9yCbVfHW4ZDjYeAV6R1-MSJgxRgbZ_s-Rf6Y4b9aeGCInApo8x04N7ySepAp3NFZWzBSRwdAzG4K9uTpTIPyy66ab_R8VHWPi40g1h4NTxpZEhmKw3Z2YQy8rS0YF_mT4LXzZSHXSiEbHjqrE39385AICKFdER4AoOatDmVnTdDFZbIi2Uv4Ig0Ya6HYrMnE7VIAx5R_vBCdvFKvufRaUSzjg%26x-client-SKU%3DID_NETSTANDARD2_0%26x-client-ver%3D5.3.0.0

We noticed there’s a difference between the URL generated from the angular client and the MVC client. While on the documentation for ASP.NET Core MVC & JQuery solutions https://docs.aspnetzero.com/en/aspnet-core-mvc/v8.2.0/Infrastructure-Core-Mvc-Identity-Server4-Integration we see in the documentation the client is having ReturnURL param as well with the same login page as the angular client.

Deat support team,

I am writing a new unit test code on the platform, however, hitting the below issue saying Service 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment' which was not registered,

below is the screenshot,

Kindly advise further and appreciate for the prompt response, thank you.

Regards Alvin T

Hi,

I'm using Asp.NetZero v 5.2.0. Before this, I managed to publish the API & Client side successfully at our staging server without any Issue. But having issue when move it to production. Even I use same source with staging, only adjusting config server & client address at appsettings.json & appconfig.json. The difference is at the server address, production side is using SSL & DNS, the staging just IP address. Both are using same port for API, only at Client side using 80 at staging, and 443 at Production caused of SSL standard port.

API side have no issue at all, Swagger UI is accessible at port 8068 (port already opened to public as well), <a class="postlink" href="https://instance.dept.gov.my:8068/AbpUserConfiguration/GetAll">https://instance.dept.gov.my:8068/AbpUs ... ion/GetAll</a> manage to returned value at production server where I deploy the angular and via public access.

Here's the error at the production: It works flawlessly when I bypass the web security by executing this command in Windows Run and navigate to production Client Address

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

Is it related to my CORS configurations? Or am I missing something? I've looked into Host project's logs at "App_Data/Logs.txt", but couldn't find any log of related issue. I've tried using 2 different config at startup, using AllowAnyOrigin()

services.AddCors(options =>
            {
                options.AddPolicy(_CorsPolicyName, builder =>
                {
                    builder
                        .AllowAnyOrigin()
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials();
                });
            });

and WithOrigins() then set the CorsOrigins with Client address at appsettings.json also with no luck

services.AddCors(options =>
            {
                options.AddPolicy(_CorsPolicyName, builder =>
                {
                    builder
                        .WithOrigins(_appConfiguration["App:CorsOrigins"]
                        .Split(",", StringSplitOptions.RemoveEmptyEntries)
                        .Select(o => o.RemovePostFix("/")).ToArray())
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials();
                });
            });

All config & startup class will send you via Email at <span style="color:#0040FF">[email protected]</span> for you to examine.

Many Thanks before.

Showing 1 to 3 of 3 entries