Link to home
Start Free TrialLog in
Avatar of solution1368
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(model);
               
                #endregion
                Response.Write(result);
            }
            else
            {
                Response.Write("Something Wrong");
            }
            return View();
        }
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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:

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);

Open in new window

Avatar of solution1368
solution1368

ASKER

System.Linq.Enumerable+d__14`2[System.Web.Mvc.ModelState,System.Web.Mvc.ModelError]

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
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial