【发布时间】:2008-11-06 16:18:09
【问题描述】:
我有这个简单的控制器:
public class OneController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Create()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(IList<TestModel> m)
{
return View(m);
}
}
还有一个非常简单的视图,其中包含两个 TestModel 类型的对象,正确索引。 当我提交包含无效数据的表单时,我会看到突出显示错误的视图。 但是,当我重新提交它(不做任何更改)时,我收到了这个错误:
[NullReferenceException: 对象引用未设置为 目的。] System.Web.Mvc.DefaultModelBinder.UpdateCollection(ModelBindingContext bindingContext,类型 itemType) +612 System.Web.Mvc.DefaultModelBinder.BindModelCore(ModelBindingContext 绑定上下文)+519 System.Web.Mvc.DefaultModelBinder.BindModel(ModelBindingContext 绑定上下文)+829 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ParameterInfo 参数信息)+313 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(MethodInfo 方法信息)+399 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext 控制器上下文,字符串动作名称) +232 System.Web.Mvc.Controller.ExecuteCore() +152 System.Web.Mvc.ControllerBase.Execute(RequestContext 请求上下文)+86 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext 请求上下文)+28 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +332 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +55 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +28 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean & completedSynchronously) +64
关于如何调试它的任何想法?
【问题讨论】:
标签: asp.net-mvc