Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello, everyone, I don't know much about MVC using in Umbraco.
I implemented my membership function by searching the google,
I create a "Login" template as following.
I used @Html.Partial method to render my partial view -"MemberLogin.cshtml" , second diagram.
The following is my code in Controller.
[HttpGet]
//[ActionName("MemberLogin")]
public ActionResult MemberLogin(string username)
{
MemberLoginModel model = new MemberLoginModel();
//if (!string.IsNullOrEmpty(username))
// model.Username = username;
return PartialView("MemberLogin", model);
}
[HttpPost]
public ActionResult MemberLogin(MemberLoginModel model)
if (ModelState.IsValid)
if (Membership.ValidateUser(model.Username, model.Password))
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
return RedirectToUmbracoPage(1063); //RedirectToAction("MemberLogin", "MemberLoginSurface"); //
else
TempData["Status"] = "Invalid username or password";
return PartialView("MemberLogin");
return PartialView(model);
I can see my Login page.
but my validation doesn't work and I redirect to my partial page wihtout css like the following diagram.
I can't find where were my mistakes. Hope someone can help me. Thank you in advanced!
Hi Michael,
1) Why do you see page without styles ? It's because you return partial view in result of your actions, you have to return all page or another solution is to make request by ajax.
2) Validation isn't working, do you have some js erros ?
Thanks, Alex
Thanks very much Alex! Yes. I totally agree with your point of view.
I return partial view in result of my actions. How can I return all page via using umbraco API?
I didn't use client-side validation,but use data annotation in the model.
public class MemberLoginModel
[Required, Display(Name = "Enter your user name")]
public string Username { get; set; }
[Required, Display(Name = "Password"), DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me")]
public bool RememberMe { get; set; }
I'm not familiar with the umbraco API, especially in MVC, it's hard to integrate MVC and Umbraco for me.
Could you give me a simple or some links related to it.
Thanks very much!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Validation in partial view.
Hello, everyone, I don't know much about MVC using in Umbraco.
I implemented my membership function by searching the google,
I create a "Login" template as following.
I used @Html.Partial method to render my partial view -"MemberLogin.cshtml" , second diagram.
The following is my code in Controller.
[HttpGet]
//[ActionName("MemberLogin")]
public ActionResult MemberLogin(string username)
{
MemberLoginModel model = new MemberLoginModel();
//if (!string.IsNullOrEmpty(username))
// model.Username = username;
return PartialView("MemberLogin", model);
}
[HttpPost]
public ActionResult MemberLogin(MemberLoginModel model)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.Username, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
return RedirectToUmbracoPage(1063); //RedirectToAction("MemberLogin", "MemberLoginSurface"); //
}
else
{
TempData["Status"] = "Invalid username or password";
return PartialView("MemberLogin");
}
}
else
{
return PartialView(model);
}
}
I can see my Login page.
but my validation doesn't work and I redirect to my partial page wihtout css like the following diagram.
I can't find where were my mistakes. Hope someone can help me. Thank you in advanced!
Hi Michael,
1) Why do you see page without styles ? It's because you return partial view in result of your actions, you have to return all page or another solution is to make request by ajax.
2) Validation isn't working, do you have some js erros ?
Thanks, Alex
Thanks very much Alex! Yes. I totally agree with your point of view.
I return partial view in result of my actions. How can I return all page via using umbraco API?
I didn't use client-side validation,but use data annotation in the model.
public class MemberLoginModel
{
[Required, Display(Name = "Enter your user name")]
public string Username { get; set; }
[Required, Display(Name = "Password"), DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me")]
public bool RememberMe { get; set; }
}
I'm not familiar with the umbraco API, especially in MVC, it's hard to integrate MVC and Umbraco for me.
Could you give me a simple or some links related to it.
Thanks very much!
is working on a reply...