mylogin 页面是部分视图。我使用 @html.Action("LogOn")
但它不能在我的登录操作中,重定向到“mainIndex”。并说 :
error executing child request for handler 'system.Web.HttpHandlerUtil+serverExecuteHttphandlerAsynWrapper
我将@html.Action("LogOn")更改为 @{html.RenderAction ("LogOn")},但没有区别。并更改为 @{Html.partialView("LogOn")}但错误:
The model item passed into the dictionary is of type 'System.String', but this dictionary requires a model item of type 'MyProject.Models.UsersClass+LogOn'.
我的代码:
[HttpGet]
public ActionResult LogOn(String returnUrl)
{
using (var db = new pakalaContext())
{
UsersClass.LogOn AllFeatureToLog = new UsersClass.LogOn();
if (User.Identity.IsAuthenticated) //remember me
{
MyClass obj = new MyClass();
if (obj.shouldRedirect(returnUrl))
{
return Redirect(returnUrl);
}
return Redirect(FormsAuthentication.DefaultUrl);
}
return PartialView(AllFeatureToLog);
}
}
public MyProject.Models.AccountModels.ControlUsers MembershipService { get; set; }
[HttpPost]
public ActionResult LogOn(UsersClass.LogOn loginInfo, string returnUrl)
{
if (this.ModelState.IsValid)
{
if (MembershipService.ValidateUser(loginInfo.usernam, loginInfo.password))
{
FormsAuthentication.SetAuthCookie(loginInfo.usernam, loginInfo.RememberMe);
MyClass obj1 = new MyClass();
if (obj1.shouldRedirect(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("MainIndex", "Home");
}
}
else
{
this.ModelState.AddModelError("LoginError", "incorrec pass or username");
}
}
return PartialView(loginInfo);
}