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

Problems with IP change by clients in Xamarin program #9327


User avatar
0
majid created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @majid

    Do you load those values when the app starts ?

  • User Avatar
    0
    majid created

    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).

  • User Avatar
    0
    ismcagdas created
    Support Team