c# - 无法从 IIS 打开数据库错误

标签 c# asp.net iis webforms

您好,我刚刚第一次尝试在 IIS 上运行我的应用程序 fopr。 在 visual studio 上开发时一切正常,但是当我将应用程序添加到 IIS 时出现此错误:

    Cannot open user default database. Login failed.
    Login failed for user 'IIS APPPOOL\forum'.

    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.Data.SqlClient.SqlException: Cannot open user default database.

当我从 visual studio 运行网站时,我应该怎么做?

编辑

我做了更多的挖掘,我设法发现我需要将我的应用程序池标识设置为 NetworkService 我这样做了,但现在我得到了另一个错误:

Unable to open the physical file "D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\App_Data\ASPNETDB.MDF". Operating system error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

最佳答案

请检查两个地方 1 访问 NetworkService 标识的文件夹(IIS 应用程序池的默认值)或此文件夹(IIS APPPOOL\forum) 2 连接字符串凭据。如果有“综合安全”。在那里提供特定的用户和密码。

关于c# - 无法从 IIS 打开数据库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13665858/

相关文章:

c# - InstallAllUsers 选项如何工作?

c# - ASP.NET MVC 重新编译限制达到 15 HostingEnvironment initiated shutdown HostingEnvironment caused shutdown

html - 配置 IIS 7.5 为 '.html' 扩展启用服务器端包含 (SSI)

c# - 停止碰撞值并重新生成对象

c# - Shouldly 断言库如何知道应用断言的表达式?

c# - Entity Framework 的导航属性为空

c# - 将传递的对象转换为某种东西

c# - 如何在回发后执行按钮单击以打开模式窗口

IIS 应用程序池 CLR v4.0 与无托管代码

powershell - 如何使用 Powershell 在 IIS 中设置 "ConnectAs"用户