I'm trying to make a log-in log-off with Ajax supported.
I made some logic in my controller to sign the user in and then return simple partial containing welcome message and log-Off ActionLink my Action method looks like this :
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (Request.IsAjaxRequest())
{
//HERE IS THE PROBLEM :(
return View("LogedInForm", model);
}
else
{
if (!String.IsNullOrEmpty(returnUrl))
return Redirect(returnUrl);
else
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
if (Request.IsAjaxRequest())
{
return Content("There were an error !");
}
}
}
return View(model);
}
and I'm trying to return this simple partial :
Welcome <b><%= Html.Encode(Model.UserName)%></b>!
<%= Html.ActionLink("Log Off", "LogOff", "Account") %>
and of-course the two partial are strongly-typed to LogOnModel.
But if i returned View("PartialName")
i always get OnFailure
with status code 500.
While if i returned Content("My Message")
everything is going right.
so please tell me why i always get this "StatusCode = 500" ??. where is the big mistake ??.