2013-08-18 48 views
0

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); 
    } 

回答

0

這個問題似乎是該LogOn()操作需要2個參數。你不能簡單地調用@{ RenderAction("LogOn"); },你要添加的參數,如:

@{ 
    var loginInfo = new UsersClass.LogOn() { /* Stuff */ }; 
    var url = Request.Url.ToString(); 
    Html.RenderAction("LogOn", new { loginInfo = loginInfo, returnUrl = url }); 
} 

所以問題是,框架是尋找一個LogOn()動作不帶任何參數,卻沒有一個。因爲它被稱爲子動作,所以你會得到這個非常詳細的錯誤。

0

如果有人來到這裏(像我一樣)在發佈修改後的源代碼到部署服務器時尋找nopCommerce 3.10中的上述錯誤的解決方案,我的問題是由於缺少插件引起的(我通過檢查DB中的日誌表)。

這是由於實際上有2個構建腳本用於準備和部署代碼(prepare.bat和deploy.bat),在發佈源代碼時必須運行它們來構建源代碼 - 這些構建Nop .Web和Nop.分別管理web應用程序,並將相關文件/插件複製到相關位置。它會創建一個可部署的目錄,您可以將其複製到部署服務器。

希望這可以幫助別人。

相關問題