Reputation: 15253
I am creating a new user programmatically (will be adding custom profiles later) and am working on Win2K8 VM:
MembershipUser newUser =
Membership.CreateUser(userNameTxt.Text, passwordTxt.Text, emailTxt.Text);
Roles.AddUserToRole(userNameTxt.Text.Trim(), "Member");
UPDATE:
Connection string:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=MYS;password=xxxxxx;"
providerName="System.Data.SqlClient" />
Getting the following error:
System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\MYAPP'.
<membership>
<providers>
<remove name="DefaultMembershipProvider"/>
<add
name="DefaultMembershipProvider"
type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<roleManager enabled="true">
Upvotes: 1
Views: 2118
Reputation: 86967
You current connection string is this:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
The error here is that you're saying: Connect to my SQL Server database and use the App Pool identity as the 'account' to authenticate my SQL Server db against.
All websites on IIS run under an 'account'. In this case, it looks like this account is called MyApp
.
So the fix you need to have a connection string that says: Don't use whatever 'identity' is setup on this IIS machine, etc. BUT! Use this hardcoded username/password instead.
Check this out, now:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=username;password=pass;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Take note:
Integrated Security=SSPI;
uid=username;
password=pass;
Just replace the values username
and pass
with the username/password you use to log into your SQL Server database.
Need help learning about what options/keywords you can define in a single connection string? Check this ConnectionStrings site as a reference.
Pro Tip: Instead of <remove name="whatever/>
.. try using <clear/>
eg.
<connectionStrings>
<clear/>
<add name="LocalSqlServer" connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=username;password=pass;" providerName="System.Data.SqlClient" />
</connectionStrings>
Upvotes: 1
Reputation: 15253
I was able to solve the connection problem by populating the aspnet_SchemaVersions table, per this link:
I was then able to connect locally thus:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
Upvotes: 0
Reputation: 124726
System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\MYAPP'.
This indicates that your application pool identity is the virtual account 'IIS APPPOOL\MYAPP'.
You need create a SQL Server login for this identity and add it as a User with appropriate permissions to the Membership database.
Not sure what you mean by create a SQL Server login for "this identity" ...
One way is to use SQL Server Management Studio. Connect "Object Explorer" to your SQL Server instance, click right on "Security / Logins" , select "New Login" and add the login name IIS APPPOOL\MYAPP with Windows Authentication.
Then map this login to a user in the Membership database.
Upvotes: 1
Reputation: 13248
Check with your connection string it should be as shown:
Server=.\SQLEXPRESS;Database=MyDatabase;Integrated Security=SSPI;
Regarding your modified error:
Set enableEventValidation to false and viewStateEncryptionMode to Never as follows:
<pages enableeventvalidation="false" viewstateencryptionmode="Never">
Upvotes: 0