OWIN - '/'应用程序中的服务器错误
好吧,所以我有这个MVC5网站,使用声明标识。OWIN - '/'应用程序中的服务器错误
OWIN抛出这个讨厌的错误:
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: 26 - Error Locating Server/Instance Specified)
如果我手动删除的 'bin' 的一切, 'OBJ' 文件夹,网站工作。
问题是,我也在部署中不时发现此错误。
SQL Server很好,工作100%。 这是从OWIN别的东西,造成这种情况。
我记得过去有过这个问题,但我记不清我做了什么来解决它。
下面是完整的堆栈跟踪:
[SqlException (0x80131904): 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: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1385
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1091
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +981
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +114
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1590
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +156
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +268
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +314
1 retry) +204
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) +245 System.Data.SqlClient.SqlConnection.Open() +130
1.Dispatch(TTarget target, Action
System.Data.Entity.Infrastructure.Interception.InternalDispatcher2 operation, TInterceptionContext interceptionContext, Action
3 executing, Action3 executed) +98
1 operation) +237
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +509
System.Data.Entity.SqlServer.<>c__DisplayClass33.<UsingConnection>b__32() +566 System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +15
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action1 act) +913
1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +117
System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable
System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) +211
3 createMigrator, ObjectContext objectContext) +121 System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +292
System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +134
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +174
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +116
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func
System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext context) +187
1.PerformAction(TInput input) +174
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +71
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +482 System.Data.Entity.Internal.RetryAction
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action) +273
1.Initialize() +77
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +38
System.Data.Entity.Internal.Linq.InternalSet
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() +21 System.Data.Entity.Internal.Linq.InternalSet
1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +69
System.Data.Entity.DbSet1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +46
1.FindAsync(Object[] keyValues) +19
System.Data.Entity.DbSet
Microsoft.AspNet.Identity.EntityFramework.d__6c.MoveNext() +198 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 Microsoft.AspNet.Identity.CultureAwaiter`1.GetResult() +48 Microsoft.AspNet.Identity.Owin.<b__1>d__4.MoveNext() +828 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Microsoft.Owin.Security.Cookies.d__2.MoveNext() +2534 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +823 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +333
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +450 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +450 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +450 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +203 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext() +193 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +119
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +365 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134
你可以尝试以下...
编辑对ApplicationHost.config通常在C:\ WINDOWS \ SYSTEM32 \ INETSRV \ config并改变setProfileEnvironment为真。
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</applicationPoolDefaults>
谢谢你的回复。我没有这个文件,我从IIS Express(Visual Studio)运行它, –
我发现了这个问题。 Startup.cs中的这3行。
我已经评论他们,现在它相应地工作。
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
这是一个DI问题,你没有在每次请求后关闭连接池对象吗? – Neil