OpenRIAServices / OpenRiaServices

The Open RIA Services project continues what was previously known as WCF RIA Services.
https://openriaservices.gitbook.io/openriaservices/
Apache License 2.0
54 stars 47 forks source link

Error 400 with .NET 8 project hosted in IIS #477

Closed KumG closed 5 months ago

KumG commented 5 months ago

Describe the bug I have a .NET 8 web project and a .NET 8 WPF application.

When I run my web project locally running the .exe , everything works fine.

When I try to run the web project with IIS Express or to deploy the project and run it in IIS, I get this error when trying to call a RIA Service method :

OpenRiaServices.Client.DomainOperationException: 'Load operation failed for query 'MyMethod'. Unexpected server statuscode 400 'BadRequest''

It only happens after I do a login. If I try to call the same method without being logged in, it works.

My client code :

DomainContext.DomainClientFactory = new BinaryHttpDomainClientFactory(new Uri(ClientConfiguration.ServerUrl, UriKind.Absolute), GetHttpClient);

var webContext = new WebContext { Authentication = new FormsAuthentication { DomainContext = new AuthenticationDomainContext() } };

Could it be something related to cookies?

In my web project, I have :

builder.Services.AddAuthentication().AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => builder.Configuration.Bind("CookieSettings", options));

Do you have an idea what the problem could be?

Daniel-Svensson commented 5 months ago

Sorry, I don't have any idea what might be wrong.

The whole problem seems a bit strange, especially since it only happens when running in IIS. That you have a method which does not require authentication which works when you are not logged in but not when logged in, might indicate that it has something to do with the authentication or cookie part.

Some things I would try to do for troubleshoting

KumG commented 5 months ago

Thank you very much for the help.

In the end, the problem wasn't directly related to OpenRIAServices. The problem was that the authentication cookie was too large. I finally used an ITicketStore to solve the problem : https://github.com/aspnet/Security/blob/22d2fe99c6fd9806b36025399a217a3a8b4e50f4/samples/CookieSessionSample/MemoryCacheTicketStore.cs