Jawad
Jawad

Reputation: 1

Umbraco contact form error. "System.InvalidOperationException: Can only use UmbracoPageResult in the context of an Http POST..."

I migrated a Umbraco website from another server and everything works fine in the new server apart from the contact form. It gives the following error messages whenever I post contact from the online contact form. I would appreciate if anyone can help resolve with resolving this issue.

Many thanks in advance.

Error Displayed:

    Server Error in '/' Application.

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: 


Line 10: </div>
Line 11: <div class="big-col-right">
Line 12:     @Html.Action("ContactUs", "ContactSurface")
Line 13: </div>

Source File: g:\pleskvhosts\test.clinisupplies.co.uk\httpdocs\Views\Contact.cshtml    Line: 12 

Upvotes: 0

Views: 722

Answers (1)

Paul
Paul

Reputation: 11

In this scenario, instead of rendering as a child action:

@Html.Action("ContactForm","ContactFormSurface")

you should render the view as a partial view:

@Html.Partial("ContactFormSurface/ContactForm")

... pointing to where the view is located.

Upvotes: 1

Related Questions