Привет! У меня ошибка: «Невозможно найти определение маршрута Umbraco в значениях маршрута, запрос должен быть сделан в контексте запроса Umbraco» и вернуть этот неверный код кода - "return RedirectToCurrentUmbracoPage();". После обжатия формы ajax.Определение маршрута Umbraco-ajax form
Это мой cotroller:
public class ContactController : Umbraco.Web.Mvc.SurfaceController
{
private string GMAIL_SERVER = "smtp.gmail.com";
private int PORT = 587;
[ChildActionOnly]
public ActionResult ContactForm()
{
var model = new ContactFormModel()
{
Email = "",
Name = "",
Subject = "",
Message = ""
};
return PartialView("ContactForm", model);
}
[NotChildAction]
[HttpPost]
public ActionResult ContactForm(ContactFormModel model)
{
var fromAddress = new MailAddress("[email protected]", model.Name);
var toAddress = new MailAddress("[email protected]", "To Name");
string fromPassword = "xxx";
string subject = model.Subject;
string body = model.Message;
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
var message = new MailMessage(fromAddress, toAddress)
{
Subject = model.Subject,
Body = "test"
};
smtp.Send(message);
return RedirectToCurrentUmbracoPage();
}
}
и этот код формы:
@using (Ajax.BeginForm("ContactForm" ,"Contact", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace }))
{
@Html.TextBoxFor(m => m.Name, null, new { name = "name", id = "name", placeholder = "Name" })
@Html.ValidationMessageFor(m => m.Name)
@Html.TextBoxFor(m => m.Email, null, new { name = "email", id = "email", placeholder = "Email address" })
@Html.ValidationMessageFor(m => m.Email)
@Html.TextBoxFor(m => m.Subject, null, new { name = "subject", id = "subject", placeholder = "Subject" })
@Html.ValidationMessageFor(m => m.Subject)
@Html.TextAreaFor(m => m.Message, new { rows = "", cols = "", name = "message", id = "message", placeholder = "Your message" })
@Html.ValidationMessageFor(m => m.Message)
<input type="submit" id="contact-submit" value="SEND MESSAGE">
}