Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • George 11 posts 52 karma points
    21 days ago
    George
    0

    Invalid model when rendering through SurfaceController behind a load balancer

    I have a surface controller that interacts with a form that has been built in a partial view. Everything works fine on my local machine and if I access our non-load-balanced admin server. When I attempt to use the form through our load balancer, I am getting an odd error:

    The model item passed into the dictionary is of type 'Elements.Models.ContactUsModel', but this dictionary requires a model item of type 'Elements.Models.ContactUsModel'.

    As you can see, the expected type and the actual type match, so I'm not sure why this error is being generated. My only thought right now is that they are coming from different compiled versions of the same class.

    I currently have all code files in App_Code and being compiled with application start up (I presume). If I precompile into a DLL, will that remedy the problem?

    Anyone know what might be happening? Any other thoughts?

  • George 11 posts 52 karma points
    20 days ago
    George
    100

    It does appear to have been related to the use of App_Code vs. a DLL. Having the files in the code folder was likely leading ASP.NET to create duplicate classes in multiple DLLs because of updates applied on the fly in the code. After compiling to a DLL, the forms work fine behind the load balancer.

    On the other hand, I appear to have broken my custom section in the back end by putting the code in a DLL. I may have to separate out the backend stuff and leave that in App_Code, but now that I've got it all in a DLL, I'm wondering if there's just a quick fix I'm missing -- maybe an assembly reference somewhere? Anyone have thoughts.

    I realize I'm changing the subject, so I'll post separately if I can't find the answer myself and no one offers one here.

  • George 11 posts 52 karma points
    1 week ago
    George
    0

    In case anyone ever reads this, I solved my second problem with an update to trees.config in the Config directory.

    My custom section had two trees. Umbraco automatically adds some configuration to Config/trees.config to load those trees. One of the attributes of my custom trees is "type." It was to something like:

    "MyNamespace.MyTreeController, App_Code"
    

    I updated it to:

    "MyNamespace.MyTreeController, MyDLLFileName"
    
Please Sign in or register to post replies

Write your reply to:

Draft