我得到错误执行处理程序的子请求

时间:2013-08-15 15:51:27

标签: asp.net-mvc asp.net-mvc-4

我的LogIn是局部视图。我将包含某些字段的tbl_profile的模型传递给局部视图并填充它然后我将填充的模型传递给[HttpPost]部分中的actionresult并且... 但现在我在[HttpGet]部分遇到了麻烦。我在这行鳕鱼 * @ Html.Action(”LogOn“,”Account“)” *上收到此错误。 我的代码:

     [HttpGet]
    public ActionResult LogOn(string returnUrl)
    {

         using (var db = new MyContext())
        {

           var  AllFeatureToLog = db.tbl_profile.Select(u => new UsersClass.LogOn { username = u.username, password_User = u.password_User }).ToList();

            return PartialView(AllFeatureToLog);
        }
    }

类:

   public class UsersClass
   {
    public class LogOn
    {
        public string username { get; set; }
        public string password_User { get; set; }
    }
   }

LogOn.cshtml:

    @model MyProject.Models.UsersClass.LogOn     
    @using (Html.BeginForm())
     {
     @Html.AntiForgeryToken()
   <form class="signin-form">

     @Html.TextBoxFor(m => m.username, new { @id = "username", @class = "input-block-       level", @placeholder = "* enter username" })
     @Html.TextBoxFor(m => m.password_User, new { @id = "password", @class = "input-block-level", @placeholder = "* enter pass" })
     @Html.ValidationMessage("LoginError")

<label class="checkbox">
    <input type="checkbox">remember me</label>
<button class="btn btn-medium btn-general input-block-level" type="submit">   enter</button>
 </form>
 }

错误:

     Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'

2 个答案:

答案 0 :(得分:0)

请改用::

@{ Html.RenderAction("LogOn","Account"); }

这将解决您的问题。

答案 1 :(得分:0)

你发送List:

var  AllFeatureToLog = db.tbl_profile.Select(u => new UsersClass.LogOn { username = u.username, password_User = u.password_User }).ToList();
return PartialView(AllFeatureToLog);

但是你的视图只有一个模型:

@model MyProject.Models.UsersClass.LogOn

更改:您的ActionResult发送一个:var AllFeatureToLog = db.tbl_profile.Select(u => new UsersClass.LogOn { username = u.username, password_User = u.password_User }).Fist();

或获取列表的视图:@model IENumerable<MyProject.Models.UsersClass.LogOn>