Iis 在具有(LocalDb)connectionstring的localhost上承载web API时无法连接

Iis 在具有(LocalDb)connectionstring的localhost上承载web API时无法连接,iis,asp.net-web-api,localhost,connection-string,localdb,Iis,Asp.net Web Api,Localhost,Connection String,Localdb,我已在本地IIS(Windows 10)上安装了web api应用程序。然后我也进入了我的主机文件,并将其设置为: api.domain.com 127.0.0.1 当我试图用邮递员发帖子时: http://api.api.domain.com/api/account/register 然后我得到以下错误: { "Message": "An error has occurred.", "ExceptionMessage": "A network-related

我已在本地IIS(Windows 10)上安装了web api应用程序。然后我也进入了我的主机文件,并将其设置为:

api.domain.com         127.0.0.1
当我试图用邮递员发帖子时:

http://api.api.domain.com/api/account/register
然后我得到以下错误:

{
    "Message": "An error has occurred.",
    "ExceptionMessage": "A network-related or instance-specific error occurred while establishing a connection to 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. (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.\r\n)",
    "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.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)\r\n   at System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass33.<UsingConnection>b__32()\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.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)\r\n   at System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript)\r\n   at System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)\r\n   at System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection)\r\n   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)\r\n   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)\r\n   at System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext)\r\n   at System.Data.Entity.Database.Create(DatabaseExistenceState existenceState)\r\n   at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)\r\n   at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)\r\n   at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()\r\n   at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)\r\n   at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)\r\n   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()\r\n   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()\r\n   at System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, Expression`1 predicate, CancellationToken cancellationToken)\r\n   at System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, Expression`1 predicate)\r\n   at Microsoft.AspNet.Identity.EntityFramework.UserStore`6.<GetUserAggregateAsync>d__6c.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.TaskExtensions.CultureAwaiter`1.GetResult()\r\n   at Microsoft.AspNet.Identity.UserValidator`2.<ValidateUserName>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.UserValidator`2.<ValidateAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.UserManager`2.<CreateAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.UserManager`2.<CreateAsync>d__d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Asano.Websites.Api.Controllers.AccountController.<Register>d__20.MoveNext() in C:\\Users\\Lars Holdgaard\\Documents\\Git\\Eesy\\Eesy\\Eesy.Websites.Api\\Controllers\\AccountController.cs:line 339\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\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.ExceptionServices.ExceptionDispatchInfo.Throw()\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.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
{
“消息”:“发生错误。”,
“ExceptionMessage”:“建立到SQL Server的连接时发生与网络相关或特定于实例的错误。找不到或无法访问该服务器。请验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。无法创建自动实例。有关错误详细信息,请参阅Windows应用程序事件日志。\r\n)“,
“ExceptionType”:“System.Data.SqlClient.SqlException”,
“StackTrace”:“在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean OnlyOnEckConnection,DbConnectionOptions userOptions,DbConnectionInternal&connection)\r\n在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(数据库连接所有者对象,TaskCompletionSource`1重试,数据库连接选项用户选项,数据库连接内部和连接)\r\n位于System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource`1重试,DbConnectionOptions用户选项,DbConnectionInternal oldConnection,DbConnectionInternal&connection)\r\n位于System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection、DbConnectionFactory connectionFactory、TaskCompletionSource`1重试、DbConnectionOptions用户选项)\r\n位于System.Data.SqlClient.SqlConnection.TryOpenner(TaskCompletionSource`1重试)\r\n位于System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重试)\r\n位于System.Data.SqlClient.SqlConnection.Open()\r\n位于System.Data.Entity.Infrastructure.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget,Action`2 operation,TInterceptionContext interceptionContext,Action`3 executing,Action`3 executed)\r\n位于System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection,DbInterceptionContext interceptionContext)\r\n位于System.Data.Entity.SqlServer.SqlProviderServices.c_uuDisplayClass33.b_uuu32()\r\n位于System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.c_uDisplayClass1.b_u0()\r\n在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1操作)\r\n在System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection,Action`1 act)\r\n在System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection-connection,Nullable`1 commandTimeout,DbConnection-sqlConnection,String-createDatabaseScript)\r\n位于System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection-connection-connection,Nullable`1 commandTimeout,StoreItemCollection-StoreItemCollection)\r\n\r\n位于System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(操作必须在System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)处\r\n位于System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext InternalContext,Func`3 createMigrator,ObjectContext ObjectContext)\r\n位于System.Data.Entity.Database.Create(DatabaseExistenceEstate ExistenceEstate)\r\n位于System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext上下文)\r\n位于System.Data.Entity.Internal.InternalContext.PerforminizationAction(Action Action)\r\n在System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()\r\n在System.Data.Entity.Internal.RetryAction`1.PerformAction(输入)\r\n在System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 Action)\r\n在System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n在System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n在System.Data.Entity.Internal.Linq.InternalSet`1.get\u InternalContext()\r\n在System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get\r\n在System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1源,表达式`1谓词,CancellationToken CancellationToken)\r\n位于System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1源,表达式`1谓词)\r\n位于Microsoft.AspNet.Identity.EntityFramework.UserStore`6.d\u 6c.MoveNext()\r\n---从引发异常的上一个位置开始的堆栈结束跟踪----\r\n在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务任务)\r\n在Microsoft.AspNet.Identity.TaskExtensions.CultureaWater`1.GetResult()\r\n位于Microsoft.AspNet.Identity.UserValidator`2.d\u\u 4.MoveNext()\r\n--来自引发异常的上一个位置的堆栈结束跟踪----\r\n位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n位于System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务)\r\n位于Microsoft.AspNet.Identity.UserValidator`2.d\u 0.MoveNext()\r\n--来自引发异常的上一个位置的堆栈结束跟踪----\r\n位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n位于System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n位于Microsoft.AspNet.Identity.UserManager`2.d\u\u 0.MoveNext()\r\n--来自引发异常的上一个位置的堆栈结束跟踪----\r\n位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n位于Sy
<add name="AsanoWebsitesApiContext" connectionString="Server=(LocalDb)\MSSQLLocalDB;Database=Eesy;Trusted_Connection=True;" providerName="System.Data.SqlClient" />