Copied to clipboard

Flag this post as spam?

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


  • Damian Green 452 posts 1433 karma points
    Jun 15, 2012 @ 11:59
    Damian Green
    0

    Use of the Token Param and demo issues

    I had some issues yesterday after getting started using this package.  The demo etc. didnt have the token param so i didnt enter anything in it and i couldnt get POST to work.  However, even with the @HTML.RenderFormToken nothing got output to the form and POST still didnt work. Only when i put some text in the formtoken did i get POST functioning correctly.

    I initially thought the token was the AntiForgery Token but its not - its just to identify the form posting back.  I think to avoid confuion this param ought to be called FormName or get rid of it completely and generate a GUID in the FormToken (and get it working / or tell me what ive done wrong) so its not needed to be entered.

    I have also then also added the [ValidateAntiForgeryToken] to the controller manually to secure my posts.  For people new to MVC this ought to be shown in the docs/demo as best practice to prevent forged requests.

    Apart from these issues and a question which il put in another thread - absolute top package! :) Im over the disappointment of 5 and looking forward to getting v4 working using MVC now (MVC was the main reason i wanted v5).

    Thanks!

    Damian

     

  • Richard Boelen 61 posts 153 karma points
    Jun 15, 2012 @ 14:33
    Richard Boelen
    0

    Hi,

    your MvcRenderMacro should contain:

     

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Devotit.Umbraco.MvcBridge.Html;
    @{
        string action Parameter.Action;
        string controller Parameter.Controller;
        string formtoken Parameter.Formtoken;
      
        @Html.RenderMvcAction(actioncontroller(umbraco.MacroEngines.DynamicNode)Model(System.Dynamic.DynamicObject)Parameterformtoken);
    }

    You need the 3 parameters in the Umbraco Macro definition.

    When you use the macro you should specify the formtoken something like:

    <umbraco:Macro action="From" controller="Contact" formtoken="contactform" Alias="MvcRenderAction" runat="server"></umbraco:Macro>
    

     

     

    hope this helps, otherwise wait for the demo update thats coming.

     

    Cheers

     

  • Damian Green 452 posts 1433 karma points
    Jun 15, 2012 @ 15:11
    Damian Green
    0

    Hi,

    I did get it working - i was missing the 

    formtoken="contactform" 

    variable initially. My question was did it need to be added as a param - could it not be generated automatically - to stop any errors as mine - or by getting a duplicate  form post.  If it stays it woould be better called FormID or FormName so it doesnt get confused with the AntiForgeryToken

    Thanks!

    Damian

  • Richard Boelen 61 posts 153 karma points
    Jun 15, 2012 @ 17:59
    Richard Boelen
    0

    I think we could just use the AntiForgeryToken for this.

    I think the post methods will not get called when there is no matching AntiForgeryToken 

     

Please Sign in or register to post replies

Write your reply to:

Draft