c# - Form Post Not working While Submission -


whenever try post form following error:

an error occurred while getting provider information database. can caused entity framework using incorrect connection string. check inner exceptions details , ensure connection string correct.

public class contactcontroller : controller {     [httpget]     public actionresult index()     {         return view(new contactmessage());     }      [httppost]     public actionresult index(contactmessage post)     {         if(modelstate.isvalid)         {             //save database             using (var db=new contactmvc.data.contactdatabase())             {                 post.datesent = datetime.now;                  db.contactmessages.add(post);                 db.savechanges();             }             //redirect             tempdata["contactmessage"] = post;             return redirecttoaction("sucessfulmessage");         }         return view(post);     }      public actionresult sucessfulmessage()     {         var message = (contactmessage)tempdata["contactmessage"];         return view(message);     } } 

you have fix connection. incorrect connection string may have different causes. try connect database server explorer in visual studio select database , press f4 (properties). can see correct connection string there. put in connection string in web.config.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -