Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Take a look at the MVC sample code for Alloy. Your post action method would typically look like this:
[HttpPost]
public ActionResult LogOn(LoginViewModel model, LoginPage currentPage)
{
if (ModelState.IsValid)
{
if (Membership.Provider.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
return RedirectToAction("Index");
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
model.Heading = currentPage.PageName;
model.MainBody = currentPage.MainBody;
model.SecondaryBody = currentPage.SecondaryBody;
return View("Index", model);
}
I have a PageControllerBase class which all controllers inherit from.
I've added a ActionResult Login(LoginModel model) method to it but I can't seem to send a request to it.
What url should the form post to? I've tried action="/login" and action="/standardpage/login" without success.
Hello Johan,
If you use the Html.BeginForm helper for your login form, then you can just pass null as a controller name and forms action attribute will be rendered with the current controller:
Html.BeginForm("Login", null, FormMethod.Post)
Thanks Sergii, I've already tried that. It just returns a Http Error 404 page. =/
Dennis, I haven't got around to working with it some more, been busy with other work but I'll let you know when I do.
I'm planning on making a partial view for logging in and I'm wondering how I can trigger the multiplexing provider to do its thing?