Can only use UmbracoPageResult in the context of an Http POST - Error
Hello everyone,
I've been trying to do a two steps form. The data is successfully sent to the controller. What I've been trying to do is basically tell the controller to return the partial view for the Step 2 form. What that did was replace the whole page with unstyled HTML, which was the partial view. Then I made this AJAX call, which sents the data successfully back, but when it reaches the point of the controller returning the partial (or returning anything really, I've tried a lot of things) it returns a
Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form
"Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below"
I tried everything and I always get this error back. I don't know what I'm doing wrong or right in this case. Can anyone point me to the correct direction, please? Any help would be very appreciated. Thanks in advance
So I have this ajax call:
$("#bookAppointment").click(function (event) {
$("#FormSubmitted").val("BookApp");
event.preventDefault();
var form = $('#ajax-back');
var formData = form.serialize();
public class BrochureSurfaceController: BaseSurfaceController
{
//There's more before that, but it's irrelevant to the question
if (model.FormSubmitted == "BookApp")
{
//check if it passes validation -It does
if (ModelState.IsValid)
{
//save specific data into the model - It does
var brochureData = new BrochureRequestData
{
Title = model.Title,
FirstName = model.FirstName,
Surname = model.Surname,
Phone = model.Phone,
Email = model.Email,
Address1 = model.Address1,
Address2 = model.Address2,
Town = model.Town,
Postcode = model.Postcode,
ProductsInterestedIn = model.ProductsInterestedIn,
Newsletter = model.NewsletterByEmail,
};
if (Brochures.SaveBrochure(brochureData))
{
model.Submitted = true;
//redirect to second page to get more data
//return PartialView("_BookAppointment", new BrochureRequestFormModel()); //This one replaces the whole page with the partial
return CurrentUmbracoPage();
}
}
else
{
Console.WriteLine("no");
}
}
}
Can only use UmbracoPageResult in the context of an Http POST - Error
Hello everyone,
I've been trying to do a two steps form. The data is successfully sent to the controller. What I've been trying to do is basically tell the controller to return the partial view for the Step 2 form. What that did was replace the whole page with unstyled HTML, which was the partial view. Then I made this AJAX call, which sents the data successfully back, but when it reaches the point of the controller returning the partial (or returning anything really, I've tried a lot of things) it returns a
Exception Details: System.InvalidOperationException: Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below"
I tried everything and I always get this error back. I don't know what I'm doing wrong or right in this case. Can anyone point me to the correct direction, please? Any help would be very appreciated. Thanks in advance So I have this ajax call:
$("#FormSubmitted").val("BookApp"); event.preventDefault();
var form = $('#ajax-back'); var formData = form.serialize();
An then I have this in my controller:
is working on a reply...