Moving DataPortal from Local to Http

Moving DataPortal from Local to Http

Old forum URL: forums.lhotka.net/forums/t/12856.aspx


johntco posted on Monday, March 30, 2015

I moved the DataPortal from running Local to be an HttpProxy, as follows:

 <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.HttpProxy,Csla" />

<

 

 

 

add key="CslaDataPortalUrl" value="http://localhost:38512/DataPortal/PostAsync" />

Whenever I try to run a Fetch method in the BO, I get weird "isSync == true" errors.

Any thoughts? Am I only able to run Async methods on the remote DataPortal? If I change to run FetchAsync versus Fetch in the BO, then I get past this, but I am getting other issues, like "Type GenericPrincipal must implement IMobileObject", which it does by inheriting from the CslaPrincipal.

ajj3085 replied on Monday, March 30, 2015

What is your client app?  Also have you tried removing /PostAsync from the URL?

johntco replied on Monday, March 30, 2015

The client app is an MVC4 Web site.

If I remove the /PostAsync from the URL, I get a 404 message: "Response status code does not indicate success: 404 (Not Found)."

 

JonnyBee replied on Tuesday, March 31, 2015

GenericPrincipal is a built-in .NET Principal type that does NOT inherit from CslaPrincipal. 

So I suspect that there is some additional logical errors in your code. 

You must also make sure to set CslaAuthentication to the correct mode and make sure that all requirements are made so that the principal is transferred on to asynchronous threads. 

johntco replied on Tuesday, March 31, 2015

I meant to say that my CustomPrincipal inherits from the CslaPrincipal. Sorry for the confusion. Regardless, it is during my login process that I am failing (at least, I am not getting past this point). I am trying to call Load method on my UserPrincipal class... so, I don't really have a principal yet at this point.

What would the correct CslaAuthentication mode be? I tried with Windows, Custom, Membership, and nothing seems to work.

ajj3085 replied on Tuesday, March 31, 2015

John Cohoon
I meant to say that my CustomPrincipal inherits from the CslaPrincipal. Sorry for the confusion. Regardless, it is during my login process that I am failing (at least, I am not getting past this point). I am trying to call Load method on my UserPrincipal class... so, I don't really have a principal yet at this point.

What would the correct CslaAuthentication mode be? I tried with Windows, Custom, Membership, and nothing seems to work.

If you're subclassing CslaPrincpal, I'd say Custom is the correct setting.  Windows is solely for Windows Integrated Authentication, Membership would be the Asp.Net membership provider. 

Are you setting the HttpContext.Current.User to be your instance?  If you're getting an error about GenericPrincipal I'd think you're not doing this.  You need to set it to your principal type even if you're not yet authenticated.  What does your Application_AuthorizeRequest look like in global.asax?

johntco replied on Tuesday, March 31, 2015

I don't have an Application_AuthorizeRequest... I have an Application_AuthenticateRequest:

 

 

 

 

 

 

 

 

 

 

 

 

 

protected void Application_AuthenticateRequest(Object sender, EventArgs e) {

 

 

 

if (Csla.ApplicationContext.User != null && Csla.ApplicationContext.User.Identity.IsAuthenticated && Csla.ApplicationContext.User.Identity is FormsIdentity) {

 

 

 

Guid userId = Guid.Parse(Csla.ApplicationContext.User.Identity.Name);

 

 

 

if (Request.Cookies["ClientId"] != null) {

 

 

 

Guid clientId = Guid.Parse(Request.Cookies["ClientId"].Value.ToString());

 

 

 

 

UserPrincipal.Load(userId, clientId);

}

 

 

 

else {

 

 

 

UserPrincipal.Load(userId);

}

johntco replied on Tuesday, March 31, 2015

Ok, I changed the Global.asax to have the following line of code just prior to those UserPrincipal.Load methods:

 

HttpContext

 

 

.Current.User = new Csla.Security.UnauthenticatedPrincipal();

That seemed to set the principal for the DataPortal, but now, I am getting those errors with "isSync == true" again when calling any mothod on the BO that is not Async.

 

 

johntco replied on Wednesday, April 01, 2015

I added a new Web Application to the ProjectTracker solution and pointed the MvcUi application to it for the dataportal, and it fails with the same "isSync == true" error.

RockfordLhotka replied on Wednesday, June 17, 2015

Thread move to GitHub:

 

https://github.com/MarimerLLC/cslaforum/issues/4

 

Copyright (c) Marimer LLC