Reputation: 2271
We are deploying an MVC2 based app on IIS at production environment floating in Internet. An error occurs and this is the process to raise it:
On Testing environment, at our intranet, this problem never had happened.
Here is the error:
// Error
Exception Error: Object reference not set to an instance of an object.
Exception Source: MagaARPIU
Exception Data: System.Collections.ListDictionaryInternal
Exception Trace: at MagaARPIU.Areas.GestionComercial.Controllers
.ProspectacionController.IngresarEmpresa(InfoEmpresa modelo)
in C:\Desarrollo\calvarez\codigo\Gacela ARP - Publicaciones\Gacela ARP\Maga\MagaARPIU\Areas\GestionComercial\Controllers\ProspectacionController.cs:line 151
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker
.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
// -- ProspectacionController.cs
105 [RolAuthorizationAttribute]
106 public ActionResult IngresarEmpresa()
107 {
108 var modelo = new InfoEmpresa();
...
113 modelo.DatosIdentificacion = new DatosIdentificacion();
...
137 return View("IngresarEmpresa1", modelo);
...
139 }
145 [HttpPost]
146 [RolAuthorizationAttribute]
147 public ActionResult IngresarEmpresa(InfoEmpresa modelo)
148 {
...
151 if (!modelo.DatosIdentificacion.Completo)
152 {
...
179 }
...
305 }
Do you know what is going on and how to solve this problem?
Upvotes: 0
Views: 230
Reputation: 1039408
It is very difficult to say why your model is null in the POST action from the information you provided. I just wonder why doesn't your code look like this instead:
[HttpPost]
[RolAuthorizationAttribute]
public ActionResult IngresarEmpresa(InfoEmpresa modelo)
{
if (ModelState.IsValid)
{
// The validation failed => redisplay the view so that the user
// can fix the errors:
return View(modelo);
}
// at this stage validation passed => do something with the model
...
}
As far as debugging your problem is concerned you probably want to put some logging inside your controller action which would trace the request parameters being sent and see what's missing.
Upvotes: 1