whenever this line execute WebSecurity.InitializeDatabaseConnection
then it is giving error "Connection string "Data Source=BBATRIDIP\SQLSERVER2008R2;Initial Catalog=test;User ID=sa,password=test#" was not found."
again LazyInitializer.EnsureInitialized
return error "An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll but was not handled in user code Additional information: Exception has been thrown by the target of an invocation."
anyone tell me where i made the mistake.
my WebSecurity.InitializeDatabaseConnection()
code look like WebSecurity.InitializeDatabaseConnection(@"Data Source=BBATRIDIP\SQLSERVER2008R2;Initial Catalog=test;User ID=sa,password=test#", "UserProfile", "UserId", "UserName", autoCreateTables: true);
thanks
this is how my connection string look like in web.config
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=BBATRIDIP\SQLSERVER2008R2;Initial Catalog=test;User ID=sa,password=tintin11#" providerName="System.Data.SqlClient" />
</connectionStrings>
but still getting error. any idea?
As you can see from MSDN signature of this method is next:
public static void InitializeDatabaseConnection(
string connectionStringName,
string userTableName,
string userIdColumn,
string userNameColumn,
bool autoCreateTables
)
So as first parameter you must provide connection name from app.config or web.config file, e.g. "SecurityConnectionString"