https://docs.aspnetzero.com/en/common/latest/Version-Updating https://github.com/aspnetzero/aspnet-zero-core
your app looks never hits the API from what the network is showing, can you check contents of: assets/appconfig.production.json make sure remoteServiceBaseUrl and appBaseUrl are pointing to the right URLs
Also, your app looks like it returns Content-Type: text/html for a JSON file instead of content-type: application/json
On IIS, did you convert the API as an Application?
When you say "The ASP.NET Core website works fine." can you elaborate? Are you able to connect to the remote swagger page from outside of the deployment server?
Also, what version of the application are you using?
And finally, can you check \App_Data\Logs\{log file} can see what it says in there when you get this error?
Here was the original issue: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS request did not succeed).
We revisited this and found that Cisco locks ports outside of generic ports - if anyone needs help with this please review:
https://www.cisco.com/c/en/us/support/docs/security/web-security-appliance/117933-qa-csc-00.html
use this site to help you test open ports: http://portquiz.net
So I had the right idea but wrong followthrough
Because a tenant 'Default' exists it tried to push me there I needed to change my app-session to this:
init(): Promise<UiCustomizationSettingsDto> {
if (environment.production && (!AppConsts.tenantName || this.checkTenant())) {
window.location.href = environment.siteRoute;
}
return new Promise<UiCustomizationSettingsDto>((resolve, reject) => {
this._sessionService.getCurrentLoginInformations().toPromise().then((result: GetCurrentLoginInformationsOutput) => {
this._application = result.application;
this._user = result.user;
this._tenant = result.tenant;
this._theme = result.theme;
resolve(result.theme);
}, (err) => {
reject(err);
});
});
}
checkTenant() {
let input = new IsTenantAvailableInput();
input.tenancyName = AppConsts.tenantName;
if (AppConsts.tenantName.toLowerCase() === 'portal') {
return false;
}
this._accountService.isTenantAvailable(input)
.subscribe((result: IsTenantAvailableOutput) => {
switch (result.state) {
case TenantAvailabilityState.Available:
console.log('Available');
return false;
case TenantAvailabilityState.InActive:
console.log('InActive');
return false;
case TenantAvailabilityState.NotFound:
console.log('NotFound');
window.location.href = environment.siteRoute;
return true;
default:
return false;
}
});
}
changeTenantIfNeeded(tenantId?: number): boolean {
if (this.isCurrentTenant(tenantId)) {
return false;
}
abp.multiTenancy.setTenantIdCookie(tenantId);
location.reload();
return true;
}
private isCurrentTenant(tenantId?: number) {
let isTenant = tenantId > 0;
if (AppConsts.tenantName.toLowerCase() === 'portal') { // this is new host
return true;
}
if (!isTenant && !this.tenant) { // this is host
return true;
}
if (!tenantId && this.tenant) {
return false;
} else if (tenantId && (!this.tenant || this.tenant.id !== tenantId)) {
return false;
}
return true;
}
@maliming - everything works except I cant access Host account any longer I noticed that the Host account on main database had tenant name of 'Default' so I assumed that would take me to Host account default.mysite.com just takes me to a tenant called default with No Host permissions
In app-session.service.ts I updated isCurrentTenant method:
private isCurrentTenant(tenantId?: number) {
let isTenant = tenantId > 0;
if (tenantId === 1 && AppConsts.tenantName.toLowerCase() === 'default') { // this is new host
return true;
} ...
I am unsure where I can alias my host account - now that http://mysite.com goes to my wordpress site
We're using Angular2/.NETCore setup and I found the AppPreBootstrap.ts file
I frankensteined a new method within AppPreBootstrap.run:
[...] const queryStringObj = UrlHelper.getQueryParameters();
// Go to External site if tenant doesn't exist
if (AppPreBootstrap.checkTenant(() => { AppPreBootstrap.getUserConfiguration(callback); })) {
window.location.href = environment.siteRoute;
}
if (queryStringObj.redirect && queryStringObj.redirect === 'TenantRegistration') { [...]
// New check method
private static checkTenant(callback: () => void): boolean {
let returnVal = false;
console.log('checkTenant');
const subdomainTenancyNameFinder = new SubdomainTenancyNameFinder();
const tenancyName = subdomainTenancyNameFinder.getCurrentTenancyNameOrNull(AppConsts.appBaseUrl);
let input = new IsTenantAvailableInput();
input.tenancyName = tenancyName;
let requestHeaders = AppPreBootstrap.getRequetHeadersWithDefaultValues();
XmlHttpRequestHelper.ajax(
'POST',
AppConsts.remoteServiceBaseUrl + '/api/services/app/Account/IsTenantAvailable',
requestHeaders,
input,
(response) => {
let result = response.result;
switch (result.state) {
case TenantAvailabilityState.Available:
returnVal = false;
break;
case TenantAvailabilityState.InActive:
returnVal = false;
break;
case TenantAvailabilityState.NotFound:
returnVal = true;
break;
}
callback();
}
);
return returnVal;
}
Failed to load resource: the server responded with a status of 400 (Bad Request) [http://localhost:19945/api/services/app/Account/IsTenantAvailable?d=1589320901545]
I kept trying with no success so I deciced to put the reroute code somewhere else. I thought app-session.service would be a good place and modified init:
init(): Promise<UiCustomizationSettingsDto> {
if (!AppConsts.tenantName || this.checkTenant()) {
window.location.href = environment.siteRoute;
}...
------------
checkTenant(): boolean {
let returnVal = false;
let input = new IsTenantAvailableInput();
input.tenancyName = AppConsts.tenantName;
this._accountService.isTenantAvailable(input)
.subscribe((result: IsTenantAvailableOutput) => {
switch (result.state) {
case TenantAvailabilityState.NotFound: //NotFound
window.location.href = environment.siteRoute;
break;
}
});
return returnVal;
}
I ended up with this which seems to do what I need it to
We have our site on mysite.com/www.mysite.com As of now, we added A records such that mysite.com goes to a wordpress site and * goes to ASPNETZero site
I am trying to setup a connection workflow so that non-tenant links redirect to wordpress instead of host Also, I need to leave open a subdomain "portal" for admins to access, Im assuming through a specific subdomain since we're restricting access to all 'failed' subdomains
I believe this is a table that explains the cases: | URL | outcome | current status | | --- | --- | --- | | mysite.com | wordpress site | working | | client.mysite.com | tenant site | working | | admin.mysite.com | Host site, IP restricted | 'works', but needs IP restrictions | | [noTenant].mysite.com | redirect to wordpress site | not working |
Looking in the API I see that the WebUrlServiceBase.cs seems to be where some of this takes place Unfortunately I am unable to debug in local and the routes only seem active in live
I found this in github which only is a local not external redirect on fail: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3958
Also, I think a possible solution would be in RedirectToExternalLoginPageAsync or something within the AccountController all together where I would test if tenant exists, if not go to mysite.com. I couldn't find specific information on rerouting within the application.
I was wondering if you had suggestions on what my approach could be?
"Azure is preventing access." this ended up being the issue
Azure had a visual error which wouldn't show that the port wasn't saved so the application was blocking all traffic Refreshed, reset Azure, all working
perfect, thanks for confirming