Hello I have a problem with the Xamarin section of the program I want the default IP address set by the server to be changed on the Xamarin program, so that the default IP address on the Xamarin program does not depend on the server. This means that users can enter their IP and be able to connect to the server with different IPs and ports
To do this, I use the following source code:
To get the Server Root Address And Tenant:
ServerRootAddress = ApiUrlConfig.BaseUrl; TenantName = _applicationContext.CurrentTenant != null ? _applicationContext.CurrentTenant.TenancyName : "";
To set the address and Tenant:
await Task.Run(() =>
{
_applicationContext.ClearLoginInfo();
Task<TS.Main.Authorization.Accounts.Dto.IsTenantAvailableOutput>
isTenantAvailableOutput;
isTenantAvailableOutput = _accountAppService.IsTenantAvailable
(new IsTenantAvailableInput() { TenancyName = TenantName });
if (isTenantAvailableOutput.Result.TenantId != null)
{
_applicationContext.SetAsTenant(TenantName,
(int)isTenantAvailableOutput.Result.TenantId);
_applicationContext.SetServerInfo(new
ServerInformation(ServerRootAddress));
UserDialogs.Instance.AlertAsync(L.Localize("ConfigConnection_Saved"),
L.Localize("ConfigConnection"), L.Localize("Ok"));
ServerInformation serv = _applicationContext.ServerInfo;
_dataStorageService.StoreTenantInfoAsync(
_applicationContext.CurrentTenant);
_dataStorageService.StoreServerInformationAsync(serv);
ApiUrlConfig.ChangeBaseUrl(ServerRootAddress);
}
});
When I set up the IP and port, it is stored correctly and I can even receive information from within the program with the new address. But when you exit the program (logout), the information is reset and returns to the default settings set on the server side.
3 Answer(s)
-
0
Hi @majid
Do you load those values when the app starts ?
-
0
Hi @ismcagdas This problem does not exist when we are in the program. But when we close the program and reopen it, the value of ApiUrlConfig is the same as the one we set on the server.
I store information in serverInformation.ServerRootAddress and ApiUrlConfig.BaseUrl at the same time(According to the above post) . As you can see in the image below, the serverInformation.ServerRootAddress value is correct, but the ApiUrlConfig.BaseUrl value returns to the previous settings(Server Side Settings).
-
0
Hi,
Could you share your
ApiUrlConfig.cs
? Do you get the new value ofBaseUrl
here https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application.Client/ApiClient/ApiUrlConfig.cs#L24 ?