CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Moving DataPortal from Local to Http

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 9 Replies | 1 Follower

    Not Ranked
    7 Posts
    John Cohoon posted on Mon, Mar 30 2015 5:09 PM

    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.

    Answered (Verified) Verified Answer

    Top 10 Contributor
    9,475 Posts
    Verified by Andy

    Thread move to GitHub:

     

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

     

    Rocky

    All Replies

    Top 10 Contributor
    4,106 Posts
    Andy replied on Mon, Mar 30 2015 7:20 PM

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

    Not Ranked
    7 Posts

    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)."

     

    Top 10 Contributor
    2,279 Posts

    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. 

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    7 Posts

    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.

    Top 10 Contributor
    4,106 Posts
    Andy replied on Tue, Mar 31 2015 8:31 AM

    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?

    Not Ranked
    7 Posts

    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);

    }

    Not Ranked
    7 Posts

    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.

     

     

    Not Ranked
    7 Posts

    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.

    Top 10 Contributor
    9,475 Posts
    Verified by Andy

    Thread move to GitHub:

     

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

     

    Rocky

    Page 1 of 1 (10 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems