Could not determine a writable folder to store the Realm file


I’m using MongoDb realm with .NET SDK. Have build and deployed a webAPI to a VPS with IIIS on it.
When accessing the API, I get the following error:

System.InvalidOperationException: Could not determine a writable folder to store the Realm file. When constructing the RealmConfiguration, provide an absolute optionalPath where writes are allowed.

This is my code

            var id = "";
            var localRealmFilePath = $"{_webHostEnvironment.ContentRootPath}" + "RealmData";

            var config = new AppConfiguration(id)
                BaseFilePath = localRealmFilePath

            var app = App.Create(config);
            var credential = Credentials.Anonymous();
            var realm = Realm.GetInstance();

            var user = await app.LogInAsync(credential);

but in the server the folder created

The issue is that you’re opening a local realm - Realm.GetInstance opens the default realm which is typically located in MyDocuments/default.realm. If you want to open a synchronized Realm (since judging by your code you’re creating an app config and logging in a user), you need to create a FlexibleSyncConfiguration and pass that to Realm.GetInstance. Alternatively, if you’re opening a local Realm, you need to specify a path your application can write to as an argument to Realm.GetInstance. Also, be sure to check out the guide for using Realm in a console application here as web api projects don’t typically have synchronization contexts.