Copied to clipboard

Flag this post as spam?

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


  • Rob Watkins 369 posts 701 karma points
    Oct 11, 2016 @ 11:12
    Rob Watkins
    0

    Route hijacking problems

    Going complete insane with the Cannot bind source type Blah to model type Umbraco.Web.Models.RenderModel message.

    I have a simple MVC membership system to provide member logins using the .NET providers. I've used it across loads of Umbraco sites with no problems.

    After trying on one site and getting the above error, I found this thread: https://our.umbraco.org/forum/using-umbraco-and-getting-started/75998-update-to-742-all-custom-hijacked-controllers-stopped-working which suggests it's a specific error with 7.4.2.

    I upgraded to 7.5.3, which broke the backend, so I downgraded to 7.4.3 which I have another site using the controller working perfectly on.

    However, I am still getting the error. The Umbraco version reports as 7.4.3. All assemblies in the two sites have been binary compared and are identical.

    I don't really know where to go from here. I need to get the login working for a client demo, and it's taken me all morning, whereas before it has literally been plug and go.

    Cut down sample of controller is:

    [ChildActionOnly]
    [HttpPost]
    public ActionResult Login(LoginViewModel model)
    {
            ActionResult res = null;
    
            MembershipControllerLoginEventArgs eargs = new MembershipControllerLoginEventArgs(false, model.UserName);
            OnLoggingIn(eargs);
    
            if (Membership.ValidateUser(model.UserName, model.Password))
            {
                    ... 
    
                    res = PartialView("UserInfo", GetUserInfo(user));
            }
    
            return res;
    }
    

    The views on both sites are identical and are:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "PublicMaster.cshtml";
    }
    
    @section pageBody {
        <div class="page login-page">
            <h1>Welcome to LMP</h1>
            @Html.Action(Request.IsAuthenticated ? "UserInfo" : "Login", "Membership")
        </div>
    }
    

    I do not understand whow I can be getting this error on a site with identical binary versions to a working site. Please help!

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Oct 11, 2016 @ 23:21
    Marc Goodson
    1

    Hi Rob

    Is it because your Login Child Action is decorated with HttpPost ?

    When you are using Html.Action to write out a Child Action, then my hunch is it's not making a Post request.

    You probably want to have a Child Action, that writes out the Login Form without a HttpPost, and then a seperate Action that IS decorated with HttpPost that handles the posting of that form, with it's LoginViewModel, runs your user validation logic.

    but I'm not sure why an identical implementation appears to work elsewhere ?

    regards

    Marc

  • Rob Watkins 369 posts 701 karma points
    Oct 13, 2016 @ 09:35
    Rob Watkins
    0

    Hmmm, what you're saying does make sense, except that this does work perfectly on probably 10+ other sites of varying older and newer versions of Umbraco!

  • Micha Somers 134 posts 597 karma points
    Oct 13, 2016 @ 10:14
    Micha Somers
    0

    Since you are saying it is working for other environments ...

    Did you compare the web.config files?

    Especially the settings for:

    • Umbraco related to membership, authentication, ModelsBuilder, ... and

    • member & role provider related stuff

    Another thing to check is if there are any special routings in place for this situation that might conflict/override/bypass your code?

    Hope this drives you back to sanity ;-)

Please Sign in or register to post replies

Write your reply to:

Draft