mylogin頁面是partialview。我使用@ html.Action(「LogOn」)錯誤執行處理程序的子請求'system.Web.HttpHandlerUtil + serverExecuteHttphandlerAsynWrapper
但它不能在我的登錄動作,重定向到「mainIndex」。 並說:
error executing child request for handler 'system.Web.HttpHandlerUtil+serverExecuteHttphandlerAsynWrapper
我改變@ html.Action( 「登錄」)到@ {html.RenderAction( 「登錄」)},但沒有指出錯誤。 和改變爲@ {Html.partialView( 「登錄」)}但錯誤:
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);
}