I have a page template called ProfileInfo.cshtml this template includes a partialview which contains a form which posts back to a surface controller.
problem 1.
If I declare the form using @using(Html.BeginUmbracoForm<PortalProfileSurfaceController>("SubmitForm") it adds the wrong action to the form (it adds the URL of the template page. I hava had to override the action to get it to post to the correct controller/action!
problem 2.
After overiding the action to get it to post to the controller, I get the following error
Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form
If I moved myModel's init code to the partial view instead of passing from the main template page and used
@inherits UmbracoViewPage instead of @model Mymodel in the partialView everything started working (except myModel was always empty in the controller), to fix that I had to do
public IActionResult SubmitForm([Bind(Prefix="vm")]ProfileModel model)
Problem posting to surface controller
I have a couple of issues.
I have a page template called ProfileInfo.cshtml this template includes a partialview which contains a form which posts back to a surface controller.
problem 1. If I declare the form using
@using(Html.BeginUmbracoForm<PortalProfileSurfaceController>("SubmitForm")
it adds the wrong action to the form (it adds the URL of the template page. I hava had to override the action to get it to post to the correct controller/action!problem 2. After overiding the action to get it to post to the controller, I get the following error
when doing
return CurrentUmbracoPage()
Any thoughts?
Managed to get it to work in the end. The problem was with passing the model to the forms partial view
and using
@model Mymodel
in the partial view.If I moved myModel's init code to the partial view instead of passing from the main template page and used
@inherits UmbracoViewPage
instead of@model Mymodel
in the partialView everything started working (except myModel was always empty in the controller), to fix that I had to dois working on a reply...