How to Use or Deal With Server-Side SDKs not Designed for Concurrency in ASP.NET Core 2.1 with Razor Pages

asp.net-core blazor c#

Question

Update: The following is a clearer explanation of what I'm attempting to do and a description of the environment in which I'm working, per its request.

In essence, I'm building a website using ASP.NET Core 2.1 and the Razor Pages framework, with everything configured according to default settings. The crucial point is that I cannot just create a database with ASP.NET and must instead utilize a specified external provider as the app's data management service. Because a client SDK for such management service is simpler to work with than a REST API, I am employing it in the server-side code for the majority of the Pages. The problem is that while the SDK was intended to be used with a single session at a time and exposes static attributes storing the session data, such the "current user," I am seeing concurrency issues. What I'm requesting is a solution to the concurrency nightmare that arises when an SDK is used that is intended to only have the client deal with one user and/or session at a time in the entire backend. I'm asking how I could possibly create a new execution or memory domain for each session that is created, so that each one can have its own "current user," or how I could otherwise solve the problem. In my earlier comments regarding Blazor, I tried to explain the simplest analog for what, in my opinion, would be a fix for this problem. I've heard of keeping session data, but as far as I'm aware, everything has to be serialized to JSON and kept in a file, which is problematic for me since the information could be private.

Old Explanation (Slightly Relevant Today): I am trying to utilize an SDK that was created to be used on an ASP.NET Core 2.1-powered website.AppDomain Information is particular to a single instance of an application and/or session; hence, the SDK contains a number of APIs that expose static data-storage components (fields, properties, etc.). This exposure structure seems to be a problem when utilizing such an SDK with ASP.NET Core since the runtime only allots one singleAppDomain the ability to share all of the sessions, and perhaps numerous unique users' sessions, on the server-side. How can I successfully utilize the SDK without being limited to being able to keep the data for one session at a time if I don't have access to this SDK's source code and/or it cannot be modified for platform-agnostic reasons? Here is a condensed explanation of the situation I'm in:

Typical API:

public sealed class User
{
    public static User ActiveUser { get; private set; } 

    public static int TotalLogCyclesThisSession { get; private set; } = 0

    public string Username { get; internal set; }

    private string Password { get; internal set; }

    public string Name { get; internal set; }

    public string AccessKey { get; }

    public User(string username, string password)
    {
        /* Populate Instance Properties with Relevant Data */

        ActiveUser = this;
    }

    public void Logout()
    {
        /* Clear Data from Settable Instance Properties */

        ActiveUser = null;
        TotalLogCyclesThisSession++;
    }
}

Assume that the static variables are used throughout the SDK.

In other words, how would I utilize the API described above in ASP.NET Core such that each session would have its own customized copy of the SDK to use, complete with session-specific static variables? If at all possible, I'm seeking for information on how to make a new Blazor "Client" assembly.AppDomain Even while I realize that the technique used by Blazor may not be appropriate given that it also has a browser-local runtime active, unlike ASP.NET Core, each session and a "Server" assembly. In the worst case, the API can be changed, but it still has to remain, for the most part, platform-agnostic. I appreciate your assistance in advance.

1
2
7/23/2018 3:15:38 AM

Popular Answer

ZZZ_tmp
2
6/28/2018 2:47:45 PM






Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow