If I create another Index action for [HttpPost] it will hit that.
Is surface controllers supposed to post to the controller and then call the desired action?
Whenever you render an Umbraco form within your view using
Html.BeginUmbracoForm<MyController>(...), the forms action will be the
URL of the current page (not the auto-routed URL of the surface
controller). Umbraco will therefore add a hidden ufprt field to the
form with an encrypted value containing the controller, action and
optional area (known as the 'Umbraco form route string'). On form
submission, this value is decrypted and Umbraco will activate the
specified action of the surface controller.
SurfaceController does not post to defined action
I have a surface controller like this:
and my view is like this:
However, when I click "Test" I get 404 instead of redirecting. What am I doing wrong?
Is it hitting the HandleTestMethod ?
If you remove [ValidateUmbracoFormRouteString] does it make any difference? (I don't think you need this as it is for Umbraco Forms)
Hi Huw
No, it's not hitting HandleTest :(
If I create another Index action for [HttpPost] it will hit that. Is surface controllers supposed to post to the controller and then call the desired action?
This is from https://docs.umbraco.com/umbraco-cms/reference/routing/surface-controllers#routing-for-plugin-based-controllers
What is the exact version of Umbraco you are using? The route decoding is done automatically, I've not had any problems posting to Surface Controllers
I'm using Umbraco 14
I just tested your code in my v14.2.0-rc site and it works fine, HandleTest gets called and redirects back to the currentpage as expected.
I think there is something else I do wrong. I made a new site and tried to add the surfacecontroller and it worked as expected.
Thanks for you help anyway :)
is working on a reply...