简体   繁体   English

在IIS DB上托管ASP.NET Web App的连接问题

[英]Hosting ASP.NET Web App on IIS DB connection problems

I have used IIS before, but I've never used a database and I've never done a web app. 我以前使用过IIS,但从未使用过数据库,也从未完成过Web应用程序。 I did the same steps for putting a site onto IIS and everything works EXCEPT for when I go to a page that has a DB connection on it. 我执行了将网站放置到IIS上的相同步骤,但是当我转到具有数据库连接的页面时,一切正常。 I've tried a lot and this is all I get. 我已经尝试了很多,这就是我所得到的。

A network-related or instance-specific error occurred while establishing a >connection to SQL Server. 建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. (提供者:SQL网络接口,错误:50-发生本地数据库运行时错误。无法创建自动实例。有关错误详细信息,请参阅Windows应用程序事件日志。

Windows Application Event Log: Windows应用程序事件日志:

Cannot get a local application data path. 无法获取本地应用程序数据路径。 Most probably a user profile is not loaded. 最有可能未加载用户配置文件。 If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user. 如果在IIS下执行LocalDB,请确保为当前用户启用了配置文件加载。

This was built in Visual Studio and I have a SQL Express DB. 这是在Visual Studio中构建的,并且我有一个SQL Express数据库。 I posted my connection strings, any help is greatly appreciated. 我发布了我的连接字符串,非常感谢您的帮助。

I have added this to my applicationHost.config: 我已将其添加到我的applicationHost.config中:

<add name="DefaultAppPool">
    <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />

And now I get: 现在我得到:

An attempt to attach an auto-named database for file |MY DB1 FILE| 尝试为文件| MY DB1 FILE |附加自动命名的数据库 failed. 失败了 A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. 存在具有相同名称的数据库,或者无法打开指定的文件,或者该数据库位于UNC共享上。

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB1.mdf;Initial Catalog=aspnet-ICCAA_VIZIER-20150223043129;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>

I was able to figure it out. 我能够弄清楚。 I changed all my data connections to .\\SqlExpress . 我将所有数据连接都更改为。\\ SqlExpress Which led me to another error of: 这导致我另一个错误:

Login failed for user 'NT AUTHORITYNETWORK SERVICE' 用户“ NT AUTHORITYNETWORK SERVICE”的登录失败

To fix this I followed this guys article to figure it out. 为了解决这个问题,我按照这篇家伙的文章加以解决。

Login Failed For user NetworkService 用户NetworkService登录失败

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM