Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
mylogin page is a partialview . and i use @html.Action("LogOn")

but it can't in my Logon action ,redirect to "mainIndex" . and says :


C#
error executing child request for handler 'system.Web.HttpHandlerUtil+serverExecuteHttphandlerAsynWrapper



i changed @html.Action("LogOn") to @{html.RenderAction ("LogOn")} , but didn't diffrent . and changed to @{Html.partialView("LogOn")} but the error :


C#
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'.



MY CODE:


C#
[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);
   }
Posted
Comments
Jameel VM 18-Aug-13 12:29pm    
which action you are trying to calling Httppost logon or HttpGetLogOn?
Jameel VM 18-Aug-13 12:34pm    
why you are using partial view?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900