Hi Michaël Vanbrabandt,
I have the same problem. And it is kinda weird.
So I have Surface Controller for log in log out the registration and forgot password requests. When I using Ajax.BeginForm without RenderRouteHandler in arguments it will give me an error. But when I typed there some random classes there like
"new { email = new EmailSender()}"
it will act okay, but after the request, it will send me to the blank page wich have the url of request and RenderRouteHandler value.
Also when i do the same request with RenderRouteHandler arguments while member logged in, it acts like normal ajax request.
Code of Controler:
enter using System.Web.Mvc;
using System.Web.Security;
using Umbraco.Web.Mvc;
using REDAirCalculator.Models.DTO;
using MailKit.Net.Smtp;
using MimeKit;
using REDAirCalculator.Models;
using System.IO;
using REDAirCalculator.DAL;
namespace REDAirCalculator.Controllers
{
public class MembersController : SurfaceController
{
private readonly IProjectRepository _projectRepository;
public MembersController(IProjectRepository projectRepository)
{
_projectRepository = projectRepository;
}
[HttpPost]
public void PasswordRecovery(Email userEmail)
{
MimeMessage message = new MimeMessage();
MailboxAddress from = new MailboxAddress("User",
"[email protected]");
message.From.Add(from);
MailboxAddress to = new MailboxAddress("User",
userEmail.EmailAddress);
message.To.Add(to);
message.Subject = "Password recovery";
BodyBuilder bodyBuilder = new BodyBuilder();
string msg = Request.Url.ToString().Replace("PasswordRecovery?emailUser=Umbraco.Core.EmailSender",
"ForgetPassword?memberGuId=" + Umbraco.MembershipHelper.GetByEmail(userEmail.EmailAddress).Id.ToString());
bodyBuilder.TextBody = msg;
message.Body = bodyBuilder.ToMessageBody();
SmtpClient client = new SmtpClient();
client.Connect("smtp.gmail.com", 465, true);
client.Authenticate("emailaddress", "password");
client.Send(message);
client.Disconnect(true);
client.Dispose();
}
}
Ajax form error
Hi, in my master template I have a Ajax.BeginForm, but on submit i get
Any ideas what could be causing this?
Hi Krum,
you will have to give more details about this.
Can you post the full code of your form including controller and model?
I think you are creating a surface controller without the surface prefix. But for that I need to see more code.
/Michaël
Hi Michaël Vanbrabandt, I have the same problem. And it is kinda weird.
So I have Surface Controller for log in log out the registration and forgot password requests. When I using Ajax.BeginForm without RenderRouteHandler in arguments it will give me an error. But when I typed there some random classes there like
"new { email = new EmailSender()}"
it will act okay, but after the request, it will send me to the blank page wich have the url of request and RenderRouteHandler value.
Also when i do the same request with RenderRouteHandler arguments while member logged in, it acts like normal ajax request.
Code of Controler:
View code:
Did you enable client validation?
Did you import required libraries?
JS libraries:
is working on a reply...