{"id":4838,"date":"2014-03-30T15:50:44","date_gmt":"2014-03-30T15:50:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/controller-modelstate-with-modelstatewrappper-collection-of-common-programming-errors\/"},"modified":"2014-03-30T15:50:44","modified_gmt":"2014-03-30T15:50:44","slug":"controller-modelstate-with-modelstatewrappper-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/controller-modelstate-with-modelstatewrappper-collection-of-common-programming-errors\/","title":{"rendered":"Controller ModelState with ModelStateWrappper-Collection of common programming errors"},"content":{"rendered":"<p>You need to provide more information, but this is my best guess as to what you have:<\/p>\n<pre><code>public class ModelStateWrapper : IValidationDictionary\n{\n    ...\n     private readonly ModelState _modelState;\n     public ModelStateWrapper(ModelState modelState)\n     {\n          _modelState = modelState;\n     }\n    ...\n}\n<\/code><\/pre>\n<p>If you want to pass a variable (the controller&#8217;s model state in this case) to the ModelStateWrapper you almost certainly need to do that explicitly by calling the ObjectFactory.<\/p>\n<p>Example:<\/p>\n<pre><code>MyController : Controller \n{\n   ...\n   public MyAction()\n   {\n      ...\n      IValidationDictionary validationDictionary = ObjectFactory\n          .With(this.ModelState)\n          .GetInstance();\n      ...\n   }\n   ...\n}\n<\/code><\/pre>\n<p>See this documentation for details:<\/p>\n<p>Passing Arguments to StructureMap at Runtime<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to provide more information, but this is my best guess as to what you have: public class ModelStateWrapper : IValidationDictionary { &#8230; private readonly ModelState _modelState; public ModelStateWrapper(ModelState modelState) { _modelState = modelState; } &#8230; } If you want to pass a variable (the controller&#8217;s model state in this case) to the ModelStateWrapper [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4838","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4838"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4838\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}