Can only use UmbracoPageResult in the context of a...
# help-with-umbraco
c
I have a form which is rendered from a View Component and posts to a Surface Controller. When it's done what it needs to, the Surface Controller tries to do a
Copy code
return CurrentUmbracoPage();
But fails with the above error. Is there something about it being instigated from a View Component rather than a Razor page directly?
d
I'm speculating, but I think this might be because you're using
Html.BeginForm
as opposed to
Html.BeginUmbracoForm
. The latter likely adds some additional data to the request that that method consumes
c
Currently doing
Copy code
return RedirectToUmbracoPage(formErrorPageId);
with the Guid of the page I want to hit, but it's ugly
Html.BeginUmbracoForm won't work
Apparently something to do with a .net bug not liking "nameof"
d
I see, I don't know anything about that unfortunately
c
If it is a bug in .net then Umbraco should probably re-work the BeginUmbracoForm or give us a work around if there is one.
d
Perhaps the weakly typed alternative works better?
Html.BeginUmbracoForm("submit", "MyFormController")
c
Think I tried that already, but willing to give it another go......
Nah, gives a 400 😦
d
400 usually means that the controller is found, but the parameters are off. The response often gives indications what's missing or else it might be a csrf-token thing that messed up somehow.
h
I will dig out an example of what I'm doing tomorrow, what umbraco version ?
c
Thanks, umb 10.6.1. I'm on Linux and I've checked the casing is correct, as that's usually the problem. But unless it's a casing issue in the Umbraco itself (wouldn't be the first time) it should be working.
h
I had issues with forms in viewcomponents, answered here https://discord.com/channels/869656431308189746/1137396880985297028
105 Views