solution1368
asked on
asp.net, mvc 3
I have below codes in Controller and the model(ClassLibrary.Bail) is not in the local Model folder. It is in reference under References folder.
My issue is: it is always returned "False" and I don't know how to fix it.
Look like if the Model is inside of the Model folder, it is working.
[HttpPost]
public ActionResult Index(ClassLibrary.Bail model)
{
if (ModelState.IsValid)
{
#region steps
int result = ServRef.AddBailBondQuote(m odel);
#endregion
Response.Write(result);
}
else
{
Response.Write("Something Wrong");
}
return View();
}
My issue is: it is always returned "False" and I don't know how to fix it.
Look like if the Model is inside of the Model folder, it is working.
[HttpPost]
public ActionResult Index(ClassLibrary.Bail model)
{
if (ModelState.IsValid)
{
#region steps
int result = ServRef.AddBailBondQuote(m
#endregion
Response.Write(result);
}
else
{
Response.Write("Something Wrong");
}
return View();
}
If you are saying that ModelState.IsValid is always false, then you should be able to find out what the errors are with the ModelState.Errors Property
ModelState.IsValid will be false if the validation for the Model fails:
Check the ModelState.Errors for what is the reason causing this by,
You have DataAnnotation which failed the incoming model.
You added custom validations.
Make sure there are no null entries in the model for non null properties
Check the ModelState.Errors for what is the reason causing this by,
var errorsMsgs = ModelState.Values.SelectMany(v => v.Errors);
ASKER
System.Linq.Enumerable+d__ 14`2[Syste m.Web.Mvc. ModelState ,System.We b.Mvc.Mode lError]
Above error is generated. Remember the model i have is not in the mvc app.
It is reference from other project that we have been using.
Above error is generated. Remember the model i have is not in the mvc app.
It is reference from other project that we have been using.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.