c# - asp.net razor fresh project failing to do membership with mysql -


simple project, fresh mvc4 razor web page, new empty mysql database. getting exception:

system.reflection.targetinvocationexception unhandled user code message=exception has been thrown target of invocation. source=mscorlib stacktrace:    @ system.runtimetypehandle.createinstance(runtimetype type, boolean publiconly, boolean nocheck, boolean& canbecached, runtimemethodhandleinternal& ctor, boolean& bneedsecuritycheck)    @ system.runtimetype.createinstanceslow(boolean publiconly, boolean skipcheckthis, boolean fillcache)    @ system.runtimetype.createinstancedefaultctor(boolean publiconly, boolean skipvisibilitychecks, boolean skipcheckthis, boolean fillcache)    @ system.activator.createinstance(type type, boolean nonpublic)    @ system.threading.lazyinitializer.lazyhelpers`1.activatorfactoryselector()    @ system.threading.lazyinitializer.ensureinitializedcore[t](t& target, boolean& initialized, object& synclock, func`1 valuefactory)    @ system.threading.lazyinitializer.ensureinitialized[t](t& target, boolean& initialized, object& synclock)    @ khswebsite.filters.initializesimplemembershipattribute.onactionexecuting(actionexecutingcontext filtercontext) in c:\users\alex\documents\visual studio 2010\projects\khswebsite\khswebsite\filters\initializesimplemembershipattribute.cs:line 21    @ system.web.mvc.async.asynccontrolleractioninvoker.invokeactionmethodfilterasynchronously(iactionfilter filter, actionexecutingcontext precontext, func`1 nextinchain)    @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass37.<>c__displayclass39.<>c__displayclass3b.<begininvokeactionmethodwithfilters>b__35()    @  system.web.mvc.async.asynccontrolleractioninvoker.invokeactionmethodfilterasynchronously(iactionfilter filter, actionexecutingcontext precontext, func`1 nextinchain) innerexception: system.invalidoperationexception    message=the asp.net simple membership database not initialized. more information, please see http://go.microsoft.com/fwlink/?linkid=256588    source=khswebsite    stacktrace:         @  khswebsite.filters.initializesimplemembershipattribute.simplemembershipinitializer..ctor() in c:\users\alex\documents\visual studio 2010\projects\khswebsite\khswebsite\filters\initializesimplemembershipattribute.cs:line 45    innerexception: system.invalidoperationexception         message=the connection string 'defaultconnection' in application's configuration file not contain required providername attribute."         source=entityframework         stacktrace:              @  system.data.entity.internal.lazyinternalconnection.initializefromconnectionstringsetting(connectionstringsettings appconfigconnection)              @ system.data.entity.internal.lazyinternalconnection.tryinitializefromappconfig(string name, appconfig config)              @ system.data.entity.internal.lazyinternalconnection.initialize()              @ system.data.entity.internal.lazyinternalconnection.get_providername()              @ system.data.entity.internal.lazyinternalcontext.initializecontext()              @ system.data.entity.internal.internalcontext.createobjectcontextforddlops()              @ system.data.entity.database.exists()              @  khswebsite.filters.initializesimplemembershipattribute.simplemembershipinitializer..ctor() in c:\users\alex\documents\visual studio 2010\projects\khswebsite\khswebsite\filters\initializesimplemembershipattribute.cs:line 34          innerexception:  

here web.config:

<?xml version="1.0"?> <configuration>   <connectionstrings>     <add name="defaultconnection" connectionstring="data source=localhost;initial     catalog=khs;integrated       security=sspi;"/>   </connectionstrings>   <system.web>     <authentication mode="forms">        <forms loginurl="login.aspx" name=".aspxformsauth"/>     </authentication>     <authorization>       <deny users="?"/>     </authorization>     <membership defaultprovider="sqlprovider" userisonlinetimewindow="15">        <providers>          <clear/>          <add name="sqlprovider" type="system.web.security.sqlmembershipprovider" connectionstringname="defaultconnection" applicationname="khs" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="true" requiresuniqueemail="true" passwordformat="hashed"/>        </providers>     </membership>     <compilation debug="true"/>   </system.web> </configuration> 

this has been taken , modified http://msdn.microsoft.com/en-us/library/6e9y4s5t(v=vs.100).aspx

any thoughts? thanks

it says have missed out provider attribute in connection string. did check provider.

something should connection string

<add name="applicationservices"          connectionstring="data source=.\sqlexpress;initial catalog=applicationservicesdb;integrated security=true;multipleactiveresultsets=true"          providername="mysql.data.mysqlclient"/> 

also, have register mysql in system.data of web.config file.

<system.data>     <dbproviderfactories>       <remove invariant="mysql.data.mysqlclient" />       <add name="mysql data provider" invariant="mysql.data.mysqlclient" description=".net framework data provider mysql" type="mysql.data.mysqlclient.mysqlclientfactory, mysql.data, version=6.3.7.0, culture=neutral, publickeytoken=c5687fc88969c44d" />     </dbproviderfactories> </system.data> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -