会话超时后抛出网络异常

会话超时后抛出网络异常

我的网站运行良好,我可以浏览整个网站,但是会话超时后,当我对页面发出另一个请求时,出现此异常:

'/' 应用程序中的服务器错误。系统找不到指定的文件描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.ComponentModel.Win32Exception:系统找不到指定的文件

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

堆栈跟踪:

[Win32Exception (0x80004005):系统找不到指定的文件]

[SqlException (0x80131904): 与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:SQL 网络接口,错误:52 - 无法找到本地数据库运行时安装。请验证 SQL Server Express 是否已正确安装以及是否启用了本地数据库运行时功能。)] 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、SqlAuthenticationProviderManager sqlAuthProviderManager) +907 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options、DbConnectionPoolKey poolKey、Object poolGroupProviderInfo、DbConnectionPool pool、DbConnection owningConnection, DbConnectionOptions 用户选项) +334 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool 池、DbConnection owningObject、DbConnectionOptions 选项、DbConnectionPoolKey 池、DbConnectionOptions 用户选项) +38 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject、DbConnectionOptions 用户选项、DbConnectionInternal 旧连接) +699 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject、DbConnectionOptions 用户选项、DbConnectionInternal 旧连接) +89 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject、UInt32 waitForMultipleObjectsTimeout、Boolean allowCreate、Boolean onlyOneCheckConnection、DbConnectionOptions 用户选项、 DbConnectionInternal& connection) +426 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +154 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +21 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry) +90 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) +443 System.Data.SqlClient.SqlConnection.Open() +96 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection t, DbConnectionInterceptionContext c) +10 System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch(TTarget target, Action2 操作,TInterceptionContext 拦截上下文,Action3 executing, Action3 已执行)+72 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection 连接,DbInterceptionContext InterceptionContext)+359 System.Data.Entity.SqlServer.<>c__DisplayClass33.b__32()+426 System.Data.Entity.SqlServer.<>c__DisplayClass1.b__0()+10 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func 1 operation) +189 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +77 System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action1 act)+174 System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection,Action 1 act) +552 System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1 commandTimeout,DbConnection sqlConnection,String createDatabaseScript)+90 System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection 连接,Nullable 1 commandTimeout, StoreItemCollection storeItemCollection) +171 System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable1 commandTimeout,StoreItemCollection storeItemCollection) +76 System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134 System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection 连接) +119 System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(操作 mustSucceedToKeepDatabase) +142 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78 System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext,Func 3 createMigrator, ObjectContext objectContext) +89 System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116 System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218 System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext 上下文) +151 System.Data.Entity.Internal.<>c__DisplayClassf 1.<CreateInitializationAction>b__e() +76 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7 System.Data.Entity.Internal.RetryAction1.PerformAction(TInput 输入) +110 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(操作1 action) +198 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +91 System.Data.Entity.Internal.InternalContext.Initialize() +30 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +16 System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +53 System.Data.Entity.Internal.Linq.InternalSet 1.get_InternalContext() +15 System.Data.Entity.Internal.Linq.InternalSet1.FindAsync(CancellationToken cancellationToken,Object[] keyValues) +53 System.Data.Entity.DbSet 1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +33 System.Data.Entity.DbSet1.FindAsync(Object[] keyValues) +26 Microsoft.AspNet.Identity.EntityFramework.EntityStore1.GetByIdAsync(Object id) +49 Microsoft.AspNet.Identity.EntityFramework.<GetUserAggregateAsync>d__6c.MoveNext() +166 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.CultureAwaiter1.GetResult() +59 Microsoft.AspNet.Identity.Owin.<b__1>d__4.MoveNext() +904 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) +58 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务) +25 Microsoft.Owin.Security.Cookies.d__2.MoveNext() +2200 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) +58 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +571 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) +58 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +255 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) +58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +182 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) +58 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext() +180 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&已完成同步)+159

版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.7.3535.0


此时,除非我删除应用程序 cookie,否则网站将无法运行。我将继续在所有页面请求中收到网络异常。我不明白我怎么能正常连接到我的数据库,然后突然无法连接到它。这就像与数据库的连接失效并且无法重新建立一样。

任何帮助将非常感激。

谢谢

答案1

堆栈跟踪表明您需要安装 SQL Server Express 并启用本地数据库运行时功能

Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled

答案2

我的问题已经解决了。原来,ApplicationDbContext 连接字符串未在发布设置配置中设置。我有另一个 dbcontext,它是应用程序使用的主要 dbcontext,并且已设置。这就是应用程序最初运行良好的原因。在调用 ApplicationDbContext 的会话超时过程中一定存在某些东西,这导致了我遇到的异常。有人能解释一下那是什么吗?

相关内容