asp.net - Pointing Simple Membership provider to use MongoDB Connection -


in mvc4 application pointed simple membership provider mongodb connection. throwing error connection string.

here code

web.config

<add name="defaultconnection" connectionstring="server=127.0.0.1;database=user" />  <membership defaultprovider="defaultmembershipprovider">   <providers>     <add name="defaultmembershipprovider" type="webmatrix.webdata.simplemembershipprovider, webmatrix.webdata" connectionstringname="defaultconnection" applicationname="/" />   </providers> </membership> <rolemanager enabled="true" defaultprovider="defaultroleprovider">   <providers>     <add name="defaultroleprovider" type="webmatrix.webdata.simpleroleprovider, webmatrix.webdata" connectionstringname="defaultconnection" applicationname="/" />   </providers> </rolemanager> 

global.asax

websecurity.initializedatabaseconnection("defaultconnection", "users", "id", "username", autocreatetables: true); 

simplemembershipprovider

 public class simplemongomembershipprovider : simplemembershipprovider  {     public override string createaccount(string username, string password)     {         websecurity.createuserandaccount(username,password, new { gender = "mal", dob = datetime.now.addyears(-1), email = "mymy@trtr.com" });         return base.createaccount(username, password);     }  } 

account controller

public class accountcontroller : controller {     public actionresult index()     {         var db = new simplemongomembershipprovider();         db.createaccount("admin", "admin");          return view();     } } 

any ideas? other step needs followed point mongodb connection

you don't appear authenticating or passing credentials mongo db, need authenticate mongo db database, there several different ways depending on usage, use instructions outlined here: http://docs.mongodb.org/ecosystem/tutorial/authenticate-with-csharp-driver/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -