简体   繁体   English

使用WEB API和Entity Framework Project的IIS本地计算机上的“基础提供程序无法打开”异常

[英]“The underlying provider failed to Open” exception on IIS Local Machine using WEB API and Entity Framework Project

I have a Web API 2 project which works perfectly with local IIS express, but when I deploy on my local machine IIS, I get the error below: 我有一个Web API 2项目,可与本地IIS Express完美配合,但是当我在本地计算机IIS上部署时,出现以下错误:

{
  "Message": "An error has occurred.",
  "ExceptionMessage": "The underlying provider failed on Open.",
  "ExceptionType": "System.Data.Entity.Core.EntityException",
  "StackTrace": "   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()\r\n   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection()\r\n   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n   at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass49.<ExecuteFunction>b__47()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction(String functionName, ObjectParameter[] parameters)\r\n   at ServiceDBUtility.FamLinkEntities.MBSP_INSERT_ERROR_LOG(String p_ID_USER, String p_ERROR_MSG, String p_ERROR_TRACE, String p_ERROR_TYPE, String p_REQUEST_URL, Nullable`1 p_ERROR_DATE)\r\n   at ServiceDBUtility.Repository.LogRepository.WriteLog(String p_ID_USER, String p_ERROR_MSG, String p_ERROR_TRACE, String p_ERROR_TYPE, String p_REQUEST_URL, Nullable`1 p_ERROR_DATE)\r\n   at ServiceDBUtility.CommonFunctions.WriteLog(String USER_ID, Exception Ex, String reqURL)\r\n   at ServiceDBUtility.CommonFunctions.ThrowException(Exception e, HttpRequestMessage request, String customErrorMessage)\r\n   at LoginService.Controllers.LoginController.Login()\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
  "InnerException": {
    "Message": "An error has occurred.",
    "ExceptionMessage": "Login failed for user ''.",
    "ExceptionType": "System.Data.SqlClient.SqlException",
    "StackTrace": "   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)\r\n   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\n   at System.Data.SqlClient.SqlConnection.Open()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()"
  }
}

Can someone provide insight into what might be causing this error? 有人可以提供有关导致此错误的原因的见解吗?

This is how I solved this issue , 这就是我解决这个问题的方法,

  1. Press WIN + R 按WIN + R
  2. Type inetmgr and press enter 输入inetmgr并按Enter
  3. Select Application pool 选择应用程序池
  4. Select Advanced Settings from Right side 从右侧选择高级设置
  5. Go to Identity and select Custom Account 转到身份并选择自定义帐户
  6. Provide Username and password of the active directory. 提供活动目录的用户名和密码。

@mahesh - By looking at the stack trace, it appears some login/authentication issue exists (find the extract from log). @mahesh-通过查看堆栈跟踪,似乎存在一些登录/身份验证问题(从日志中找到摘录)。 Please check the credentials/access on SQL Server. 请检查SQL Server上的凭据/访问权限。

d__1.MoveNext()", "InnerException": { "Message": "An error has occurred.", "ExceptionMessage": "Login failed for user ''.", "ExceptionType": "System.Data.SqlClient.SqlException", "StackTrace": " at d__1.MoveNext()“,” InnerException“:{”消息“:”发生错误。“,” ExceptionMessage“:”用户“登录失败。”,“ ExceptionType”:“ System.Data.SqlClient.SqlException ”,“ StackTrace”:“位于

For future references, this is usually an SQL Server error, before touching your code, open SQL Server Management Studio, see if you're able to login, chances are you won't be. 为了将来参考,这通常是SQL Server错误,请在触摸代码之前打开SQL Server Management Studio,看看您是否能够登录,可能不会登录。 Then open SQL Server Configuration Manager and make sure your server is running. 然后打开SQL Server配置管理器,并确保您的服务器正在运行。

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

相关问题 实体框架异常“底层提供程序打开失败” - Entity Framework Exception “The underlying provider failed on Open” NServiceBus和实体框架导致异常-基础提供程序在打开时失败 - NServiceBus and Entity Framework causes exception - The underlying provider failed on Open 实体框架给出异常:“底层提供程序在打开时失败。” - Entity Framework giving exception : “The underlying provider failed on Open.” 在实体框架上下文中使用单例模式-基础提供程序在打开时失败 - Using singleton pattern with Entity Framework context - The underlying provider failed on open 基础提供程序无法打开-WPF和实体框架 - The underlying provider failed to open - WPF and Entity FrameWork 实体框架底层提供程序在打开时失败 - Entity Framework The underlying provider failed on Open 基础提供程序在实体框架中打开时失败 - The underlying provider failed on Open in entity framework connection 基础提供程序在IIS中打开时失败 - The underlying provider failed on Open in IIS 基础提供程序因iis7中的wcf中的Open异常而失败 - The underlying provider failed on Open exception in wcf in iis7 具有SQLite异常的实体框架:底层提供程序在Commit上失败 - Entity Framework with SQLite exception: The underlying provider failed on Commit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM