Porting from .NET Framework 4.8 to .NET Core 8

I hadn’t realized that the problem was using JsonServiceClient instead of JsonApiClient. Using JsonApiClient, as you told me, everything is working correctly now.
Does this mean I also have to migrate my client application from .NET Framework to .NET Core? I don’t think there’s a way to keep my client application in .NET Framework and still connect to the new .NET Core server, is that correct?

Thank you so much for your help; I should have everything I need to move forward now.

If it works you don’t have to. I’ve pushed a pre-release version of ServiceStack v10.0.7 where GetPublicKey is marked with IGet so it can be called via your Get as you were doing before.

A major difference between .NET and .NET Framework is that APIs are only available on the primary HTTP Method, instead of ServiceStack where APIs were typically available from all HTTP Methods.

Thanks for the pre-release. I tried it out. If I use the test client I built yesterday (which was working yesterday), I get the “Method Not Allowed” error. If, on the other hand, I try using the .NET Framework client, I get the error “Underlying connection closed: Unexpected error during a send operation…”.

I’m just letting you know.

In the meantime, I’ll run some more tests and let you know.

Hi again,
Thanks to your advice, I can make unauthenticated calls, but when I need to authenticate, I run into problems.

To continue using the old CustomCredentialsAuthProvider, I’m starting the server like this:

public void Configure(IWebHostBuilder builder) => builder
    .ConfigureServices(services =>
    {
        //Enable Authentication
        services.AddPlugin(new AuthFeature(() => new AuthUserSession(),
            [
                new CustomCredentialsAuthProvider(),
            ]
        ));

I’ve also added manual routing like this:

Routes.Add<AuthenticateService>("/auth", "POST");
Routes.Add<AuthenticateService>("/auth/{provider}", "POST");
Routes.Add<AssignRolesService>("/assignroles", "POST");
Routes.Add<UnAssignRolesService>("/unassignroles", "POST");

But when I try to make the authentication call from the client, I always get the error “Method not allowed”.

For completeness, here is the call that gives me an error on the client side:

              using (JsonApiClient client = new JsonApiClient($"http://{IpAddress}:{PortHttp}/"))
              {
                  AuthResponse = client.Post(new Authenticate
                  {
                      provider = CredentialsAuthProvider.Name,
                      UserName = _gp.CurrUser.Base64Encode(),
                      Password = _gp.Password.Base64Encode(),
                      RememberMe = true,
                  });

What am I doing wrong?

Thank you.

PS
I’ve reverted to version 10.0.6 of the libraries

Don’t add duplicate routes, the AuthFeature plugin has it’s own routes.

As I said previously you shouldn’t using with HttpClient, the lifetime should be managed from the IOC which you can get with dependency injection. Otherwise just use a singleton instance, instead of creating/disposing a HttpClient each time.

Explain the type of App that’s running the client and the server you’re trying to connect to. E.g. what version of .NET, ServiceStack and if they use Endpoint Routing.

In the server you’re trying to connect to (i.e. that has AuthFeature plugin) are you able to authenticate with the UI form? https://localhost:5001/ui

I am using .NET Core 8 and ServiceStack version 10.0.6, and I am porting the application from .NET Framework 4.8 with ServiceStack version 8.0.0.

I’m now trying to see if I can authenticate via the UI; in the meantime, I’m trying to use the application without client authentication, and in the responses I’m losing class inheritance. Let me explain. In a response I have an array of class A; from the server I send an array of B which inherits from A, but I receive an array of A. In the previous .NET Framework version, I didn’t experience this behaviour.
Am I missing something?