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

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -