Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys, I have a strange problem when I deploy my website to my production environment. During development when I post my form back to the controller the ModelState is valid but after deploying to the production enviornment in IIS the ModelState is always invalid after entering in the exact same data. Has anyone seen this behaviour before and any ideas what I need to do to solve it.

Thanks for your help.
Posted

This could be because you are connecting to a different database in Production and this could be returning wrong / unexpected values while running the code.
 
Share this answer
 
Sounds like the old "Works on my machine" problem. Check the database of both production and your development (test/acceptance?) machines. Look at validations that could easily break due to cultural differences like dates for example. Check machine language and culture settings and make sure your validations are culture-neutral.

Hopefully the above helps you out, otherwise you might want to update the question and add some more detailed info.

Good luck!
 
Share this answer
 
Hey Guys, I figured out a way to see what properties in the model state we actually invalid. Hope this helps somebody else....


C#
 ICollection<modelstate> _collection = ModelState.Values;
                    foreach (ModelState _modelState in _collection)
                    {
                        ModelErrorCollection _errors = _modelState.Errors;
                        foreach (ModelError _error in _errors)
                        {
                            //write to event log etc......
                        }

                    }

</modelstate>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900