I just started playing with Umbraco 7.6.5. today. I tried creating a contact form via MVC but I am getting the following message when I try to load my page in the browser...
A route named 'SubmitForm' could not be found in the route collection.
Parameter name: name
using Umbraco.Web.Mvc;
using System.Web.Mvc;
using umb00.Models;
using System.Net.Mail;
namespace umb00.Controllers
{
public class ContactFormController : SurfaceController
{
public const string PARTIAL_VIEW_FOLDER = "~/Views/Partials/Contact/";
public ActionResult RenderForm()
{
return PartialView(PARTIAL_VIEW_FOLDER + "_Contact.cshtml");
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SubmitForm(ContactForm model)
{
if (ModelState.IsValid)
{
//send an email
SendEmail(model);
return RedirectToCurrentUmbracoPage();
}
//if not valid go back to the page
return CurrentUmbracoPage();
}
private void SendEmail(ContactForm model)
{
MailMessage message = new MailMessage(model.EmailAddress, "admin@umbraco.00.local");
message.Subject = string.Format("Enquiry from {0} {1} - {2}", model.FirstName, model.LastName, model.EmailAddress);
message.Body = model.Message;
SmtpClient client = new SmtpClient("127.0.0.1", 25);
client.Send(message);
}
}
}
Missing route from route collection
I just started playing with Umbraco 7.6.5. today. I tried creating a contact form via MVC but I am getting the following message when I try to load my page in the browser...
My ContactForm view looks like this...
My _Contact partial view looks like this:
and my ContactFormController looks like this:
Any advice would be great thanks!
Hi,
when doing form stuff always use BeginUmbracoForm so that umbraco can wire up the routing correctly.
Would be my first guess on what's wrong.
Regards David
Hi,
Looks like you're following one of the Paul's YouTube tutorials. Theses are great.
I have the same issue when following this once, and never resolved the issue, although I didn't try using BeginUmbracoForm like David suggested.
The way i fixed this was to stop Umbraco from running, and rebuild the solution.
~ Lewis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.