2015-05-04 48 views
0

我正在使用ASP.NET内置方法进行用户身份验证和成员资格,该方法使用存储在我的项目的App_Data文件夹中的SQL Server平面文件(.mdf)解。ASP.NET内置用户身份验证生产连接字符串

我有这个地方工作,但是当我部署到虚拟专用服务器(VPS)我收到以下错误消息:

而与SQL Server建立连接时出现与网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,并将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 错误定位指定的服务器/实例)

这里是我的连接字符串:

<add name="DefaultConnection" connectionString="Data Source=IP_ADDRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30 User ID=USERNAME;Password=PASSWORD" providerName="System.Data.SqlClient"/> 

回答

0

我不使用本地文件.MDF为SQL Server,但尝试如下:

<add name="DefaultConnection" connectionString="AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Connect Timeout=30;User ID=USERNAME;Password=PASSWORD" providerName="System.Data.SqlClient"/> 

尝试在本地,看看它是否工作。如果它在本地工作,然后在您的VPS上尝试它。我猜测对于本地文件来说,“集成安全性”并不重要。另外,您在User ID之前错过了;,我不确定为什么IP地址对本地文件很重要。

+0

哎呦我添加注释,但意思是这样回应 – Ben

0

修正了分号,仍然显示相同的错误消息,但现在也:

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102 . If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist. If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database. Sql Server Express must be installed on the machine. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.

+0

,你有没有按照这些步骤,现在做它为你工作? –