Copied to clipboard

Flag this post as spam?

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


  • Robert Stigsson 47 posts 158 karma points
    Nov 26, 2015 @ 13:48
    Robert Stigsson
    0

    Contour submit calls Html.Action from other controller

    Hi!

    Our webpage has a Login-form in our header and a form in our body. When submitting the form from our body, the form in the header is also sent. Showing some code might clear it up:

    At LoginSurfaceController we have:

    [HttpGet]
    public PartialViewResult Login()
    {
        var vm = MemberBuilder.BuildMemberLoginVM();
        return PartialView("_Login", vm);
    }
    
    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<JsonResult> Login(MemberLoginVM model)
    {
        var response = LoginBuilder.Login(model); 
        return Json(response);
    }
    

    And in the TestForms.cshtml it looks like this:

    @if (!user.IsAuthenticated)
    {
        @Html.Action("Login", "LoginSurface")
    }
    @CurrentPage.GetGridHtml("gridContent", "Bootstrap3")
    

    In the gridContent I have added a form. It renders correctly, and so does the Login-form.

    When I log in with the Login-form, everything works fine. But if I'm not logged in and I'm submitting the contour-form, I come to a completly empty white page, after I've got an exception from the Login(MemberLoginVM model)-function. Instead of, as when I'm rendering the page the first time, the LoginSurface does not call for the GET-function, but instead call the POST-function with null as model.

    Do you know why this is happening? Are we doing something wrong, or do we have to modify the contour-view in some way?

Please Sign in or register to post replies

Write your reply to:

Draft