asp.net mvc - Return action does not work correctly -


i have simple create action save product db. after saving product have used return view(new product()); reset form fields form show old data(the data before submit form). use return view(new product(name="test")); not work too. problem? product saved db correctly (it means modelstate.isvalid true). don not want use redirecttoaction.

    [httppost]     public actionresult new(product product)     {         if (modelstate.isvalid)         {             product.submitdate = datetime.utcnow;             productrepository.add(product);             productrepository.save();              //viewbag.message = "product saved";             return view(new product());         }          return view(product);     } 

i think recommended practice use redirecttoaction() if want try way, try

 modelstate.clear();  return view(new product()); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -