简体   繁体   English

如何将 SQL 数据库连接到 web 上的 IIS 的网站托管站点?

[英]How can I connect a SQL database to a webhosted site with IIS on the web?

I am building a test web application in asp.net core and I have hosted my site from laptop.我正在 asp.net 核心构建一个测试 web 应用程序,我已经从笔记本电脑托管了我的网站。 Everything seems good but when I go to access any database related page the page just loads for a bit until it gives me an error and prompts me to go developer mode to see more relevant information(which I can't because the site is not on localhost it is on the web).一切似乎都很好,但是当我 go 访问任何与数据库相关的页面时,页面只加载了一点,直到它给我一个错误并提示我进入 go 开发人员模式以查看更多相关信息(我不能,因为该网站不在localhost 它在网络上)。 I tried to change my connection string to different iterations it did not work, the site works locally with IIS express.我试图将我的连接字符串更改为不同的迭代它不起作用,该站点在本地使用 IIS 快递。 Frankly I do not know what to do the documentation seems to be not existent so I would appreciate your help.坦率地说,我不知道该怎么做,文档似乎不存在,因此非常感谢您的帮助。 You can test the website at http://digital60.ddnsking.com/ .您可以在http://digital60.ddnsking.com/测试网站。

The connection string in use is:使用的连接字符串是:

"ConnectionStrings" : {
   "Default": "Data Source=DESKTOP-BULSITK\\SQLEXPRESS;Initial Catalog=TimsDinerDB;Integrated 
    Security=True;Connect 
Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}

The database related pages are Create Order, List Foods, List Orders数据库相关页面是Create Order, List Foods, List Orders

This setup as mentioned previously works locally but when I host my site on the web it just does not connect, the hosting occurs from laptop in both cases(no change of OS or hardware on anything).前面提到的这种设置在本地有效,但是当我在 web 上托管我的网站时,它只是不连接,在这两种情况下都从笔记本电脑进行托管(操作系统或硬件没有任何变化)。 I cannot post all the code of the test site here but if it is necessary I could put all the code in github, but I do not thing this is the problem.我不能在这里发布测试站点的所有代码,但如果有必要,我可以将所有代码放在 github 中,但我不认为这是问题所在。

Ok so after a lot of hours I fixed it, I am not exactly certain what fixed it but I believe it was probably my changes on the connection string, So the final connection string was:好吧,经过几个小时我修复了它,我不确定是什么修复了它,但我相信这可能是我对连接字符串的更改,所以最终的连接字符串是:

"ConnectionStrings": {
"Default": "Server=.\\SQLExpress;Initial Catalog=TimsDinerDB;User Id=sa;Password=[Password];Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"}
}

you have to first activate the sa(server administrator) user from sql server for this one to work, and fill the password with the password you add to the sa user.你必须首先从 sql 服务器激活 sa(服务器管理员)用户才能工作,并使用你添加到 sa 用户的密码填写密码。 I will try to see if it can be done with other users too.我会尝试看看是否也可以与其他用户一起完成。 Other change I made was in security to add the IUSRS permissions to read write and modify but I am not certain if that was necessary.我所做的其他更改是在安全性方面添加 IUSRS 读写和修改权限,但我不确定是否有必要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何连接到phpMyAdmin中的另一个SQL数据库? - How can I connect to another SQL database in phpMyAdmin? VS C#网站登录工具可连接到非默认SQL数据库 - VS C# Web Site Login Tool to connect to non-default SQL Database 网站管理工具:无法连接到 SQL Server 数据库(使用 SQL Server 开发版) - Web Site Administration Tool: Unable to connect to SQL Server database (using SQL Server Development Edition) 如何将节点应用程序连接到Azure SQL数据库? - How can I connect my node app to my azure sql database? 如何远程连接到SQL Server? - How can I connect to SQL Server remotely? 如何在VS Express 2012 for Web中连接到SQL Server数据库 - How to connect to SQL Server database in VS Express 2012 for Web web 站点的 SQL 数据库存储的替代品有哪些? - What are alternatives to SQL database storage for a web site? 我可以在没有Web服务的情况下从C#桌面应用程序连接到Sharepoint上的SQL Server数据库吗? - Can I connect from my C# desk top application to an SQL Server database on Sharepoint without a web service? 将eclipse Web应用程序连接到sql 2012数据库 - connect eclipse web application to sql 2012 database 如何通过App.config文件中的WPF使用IP连接到远程SQL数据库? - How can I connect to a remotely SQL database using IP via WPF in App.config file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM