Symptom: Run from Visual Studio. However, if you cannot log on from IIS (or remotely log on), the system prompts "the host name \ ASPnet logon failed and the default database cannot be opened"
Solution:
1. ASP. NET user-managed data is stored in the aspnetdb. MDF file and accessed during login. So attach the database to SQL Server first.
2. Go to the security directory of the database, create a user, and add the ASPNET user
3. Double-click the ASPNET user. In the displayed dialog box, select all the following database role members.
4. Go to the security directory under the instance and double-click the ASPNET user. In the displayed dialog box, the default database is set to aspnetdb.
After completing the preceding steps, you can log on to
Next we will talk about the arrangement of other databases. For example, there is also a database. MDF, And the connectionstring automatically generated by vs cannot be remotely connected.
1. Attach database. MDF to SQL Server and make the following settings (select public and db_datareader as the role)
2. Change connectionstring to the following format and specify the name of the database to be connected in the connection string.
<Connectionstrings>
<Add name = "connectionstring" connectionstring = "Data Source =. \ sqlexpress; Integrated Security = true; database = Database"
Providername = "system. Data. sqlclient"/> <! -- Identical? -->
</Connectionstrings>
This method has one disadvantage, that is, the default database of ASPNET users can only have one, so this method is only suitable for the use of user management for only one website.