配置 web.config 以使用 GoDaddy 托管进行部署
我使用 Visual Studio Web Developer 2010 Express 进行开发时有以下连接字符串:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\BegASPNET\Cheeztest\App_Data\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res://*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
我需要更改/删除/保留什么才能使用以下参数连接到 GoDaddy 帐户:
主机名:someresource.com 数据库名称:databasedb 用户名:数据库db 密码:
我在仅允许单个 MS SQL 数据库的 GoDaddy 帐户上托管的密码。在开发过程中,我有两个独立的数据库;一个是 ASPNETDB.MDF,另一个是 Database.MDF。我是否还需要在托管环境中拥有两个独立的数据库?
我忘了提及,是的,GoDaddy 确实提供了配置字符串。我已经尝试了两天,但没有成功,这就是我在这里发帖的原因。
GoDaddy 提供的字符串是:
Data Source=somesource.com; Initial Catalog=databasedb;User ID=databsedb; Password=password;
另外,如果有必要,我可以升级我的 GoDaddy 帐户并获取另一个数据库。如果这能让我的生活更轻松,我愿意这样做。
更新:
我将连接字符串更改为:
<add name="ApplicationServices" connectionString="data source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res:
//*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=leqaspnetdb.db.8311806.hostedresource.com;
Initial Catalog=leqaspnetdb;User ID=leqaspnetdb;Password=Dan13206;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
我收到此错误:
路径中存在非法字符。
描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.ArgumentException:路径中存在非法字符。
I have the following connection strings in development using visual studio web developer 2010 express:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\BegASPNET\Cheeztest\App_Data\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res://*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
What do I need to change/delete/keep in order to connect to a GoDaddy account with the following parameters:
Host Name: someresource.com
Database Name: databasedb
Username: databasedb
Password: password
I am hosting on a GoDaddy account that only allows a single MS SQL database. In development I had two separate databases; one was ASPNETDB.MDF and the other was Database.MDF. Do I also need to have two separate databases in the hosted environment?
I forgot to mention that yes, GoDaddy does provide a configuration string. I have been trying for two days to make it work without success which is why I am posting here.
The string provided by GoDaddy is:
Data Source=somesource.com; Initial Catalog=databasedb;User ID=databsedb; Password=password;
Also, if necessary I can upgrade my GoDaddy account and get another database. Which I am willing to do if it will make my life easier.
UPDATE:
I changed connection strings to this:
<add name="ApplicationServices" connectionString="data source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res:
//*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=leqaspnetdb.db.8311806.hostedresource.com;
Initial Catalog=leqaspnetdb;User ID=leqaspnetdb;Password=Dan13206;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
And I get this error:
Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Illegal characters in path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要不存在架构冲突,您当然可以在托管环境中使用一个数据库。
您可以在 web.config 中有多个连接字符串指向同一个数据库。
以下是discountasp.net 托管的示例连接字符串(抱歉,goDaddy 没有任何内容)。
如果仍有问题,请描述问题所在。
You can certainly use one database in your hosted environment as long as there are no schema conflicts.
You can have multiple connectionStrings in web.config pointing to the same database.
Here is an example connection string for discountasp.net hosting (sorry have nothing with goDaddy).
If you still have any problem, please describe what the problem is.
以下是有关 Godaddy 连接数据库的文档:
(http://support.godaddy.com/help/article/256/connecting-to-a-microsoft-sql-server-database-using-aspado?locale=en&ci=4606)
此示例描述使用 ASP/ADO 连接到 Microsoft SQL Server 数据库。
将 db_ 字段替换为主机帐户控制面板中数据库的信息。有关详细信息,请参阅查找 MS SQL 数据库连接字符串以获取更多信息。
Below is documentation on Godaddy about connecting to its database:
(http://support.godaddy.com/help/article/256/connecting-to-a-microsoft-sql-server-database-using-aspado?locale=en&ci=4606)
This example describes using ASP/ADO to connect to a Microsoft SQL Server Database.
Replace the db_ fields with the information for your database from the Control Panel in your hosting account. For more information, see Locating Your MS SQL Database Connection Strings for more information.