调试已发布的ASP.NET项目时出错 [英] Error while debugging published ASP.NET project

查看:83
本文介绍了调试已发布的ASP.NET项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个解决方案,我使用Visual Studio 2015和SQL Server 2014.



我使用连接类型文件系统发布项目。



将已发布的文件复制到IIS管理工具之后。



虽然调试项目没有连接到本地数据库。



给出连接字符串,如

< add name =abcdconnectionString =data source = myServerAddress; initial catalog = mydatabase; integrated security = True; providerName =System.Data.SqlClient/>





我收到错误,



System.Data.SqlClient.SqlException(0x80131904):无法打开登录请求的数据库mydatabase。登录失败。用户'IIS APPPOOL \DefaultAppPool'登录失败。在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,UInt32的waitForMultipleObjectsTimeout,布尔allowCreate,布尔onlyOneCheckConnection,DbConnectionOptions USEROPTIONS,DbConnectionInternal&安培;连接)在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,TaskCompletionSource`1重试,DbConnectionOptions System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory)上的System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource`1 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& connection)中的userOptions,DbConnectionInternal& connection) System.Data.SqlClient.SqlConnectio的System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)中的connectionFactory,TaskCompletionSource`1 retry,DbConnectionOptions userOptions)在PayRoll.AdminLogin.Button1_Click(Object sender,EventArgs e)的System.Data.SqlClient.SqlConnection.Open()中尝试打开(TaskCompletionSource`1重试)ClientConnectionId:4f84ac56-d0ec-4ce6-aa8b-300aca58ca81错误号码:4060,州:1,等级:11



我尝试过:



我点了这个链接。 

https://www.c-sharpcorner.com/UploadFile/francissvk/how-to-publish-Asp-Net-web-application-using-visual-studio-2/

解决方案

这可能是因为您的连接字符串正在使用集成安全性。这意味着在服务器上运行ASP.NET代码的帐户是用于登录SQL Server的帐户,该帐户没有权限这样做。



我的建议是创建一个对数据库具有适当权限的帐户,并更改连接字符串以使用该帐户,而不是使用集成安全性。


I need a solution,I Am using Visual studio 2015 and SQL server 2014.

I published project using Connection type File system.

After that published files are copied to the IIS admin tool.

While debugging project is not connecting to local database.

Connection string is given like
<add name="abcd" connectionString="data source=myServerAddress;initial catalog=mydatabase;integrated security=True;" providerName="System.Data.SqlClient" />


I got error like,

System.Data.SqlClient.SqlException (0x80131904): Cannot open database "mydatabase" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\DefaultAppPool'. at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at PayRoll.AdminLogin.Button1_Click(Object sender, EventArgs e) ClientConnectionId:4f84ac56-d0ec-4ce6-aa8b-300aca58ca81 Error Number:4060,State:1,Class:11

What I have tried:

I followed this link. 

https://www.c-sharpcorner.com/UploadFile/francissvk/how-to-publish-Asp-Net-web-application-using-visual-studio-2/

解决方案

It's probably because your connection string is using "Integrated Security". That means the account that's running your ASP.NET code on the server is the account being used to login to SQL Server and that account doesn't have permissions to do so.

My suggestion is to create an account that has appropriate permissions to the database and change the connection string to use that account instead of using Integrated Security.


这篇关于调试已发布的ASP.NET项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆