I have been working with Umbraco 7 for quite a while now. And I have come across diffrent ways to create a contact form.
One uses the UmbracoApiController. And types the method in the controller to a string, and returns: return SerializeObject(new { success = true });
And to get the fields of the form uses:
Current.Request.Form["name"];.
And one uses the UmbracoSurfaceController, Creates an view model and in the controller types the method to an ActionResult and passes in the model. And returns either a partial views if it's an ajax call or return RedirectToCurrentUmbracoPage();. And to get the fields of the form uses:
model.Name.
So my question is: Is one of these option better than the other or is one way more preffer that the other, or how do you create your form?
My opinon is that using the UmbracoApiController is a bit faster to write and more dynamic if you want to do hotfixes when in production, or just to add fields.
Contact form, UmbracoApiController vs UmbracoSurfaceController
Hello evryone!
I have been working with Umbraco 7 for quite a while now. And I have come across diffrent ways to create a contact form.
One uses the UmbracoApiController. And types the method in the controller to a string, and returns:
return SerializeObject(new { success = true });
And to get the fields of the form uses:
Current.Request.Form["name"];
.And one uses the UmbracoSurfaceController, Creates an view model and in the controller types the method to an ActionResult and passes in the model. And returns either a partial views if it's an ajax call or
return RedirectToCurrentUmbracoPage();
. And to get the fields of the form uses:model.Name
.So my question is: Is one of these option better than the other or is one way more preffer that the other, or how do you create your form?
My opinon is that using the UmbracoApiController is a bit faster to write and more dynamic if you want to do hotfixes when in production, or just to add fields.
Would love you know you guys opinions!
//Johannes
Hi Johannes
Api is for Api
Surface controllers is for forms and for child view logic.
But all other is just your preferences.
Thanks, Alex
is working on a reply...