Network Exception thrown after session timeout

0

My site will run fine and I can go through the entire site, but after my session times out, when I make another request to a page I get this exception:

Server Error in '/' Application. The system cannot find the file specified Description: An un-handled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Win32Exception (0x80004005): The system cannot find the file specified]

[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: 52 - 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.)] 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 userOptions) +334 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +699 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 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, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +154 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +21 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 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.InternalDispatcher1.Dispatch(TTarget target, Action2 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed) +72 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, 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(Func1 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, Action1 act) +552 System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +90 System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable1 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 connection) +119 System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78 System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func3 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 context) +151 System.Data.Entity.Internal.<>c__DisplayClassf1.<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 input) +110 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 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.InternalSet1.get_InternalContext() +15 System.Data.Entity.Internal.Linq.InternalSet1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +53 System.Data.Entity.DbSet1.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(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +25 Microsoft.Owin.Security.Cookies.d__2.MoveNext() +2200 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +571 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +255 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +404 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +182 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +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 step, Boolean& completedSynchronously) +159

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3535.0


At this point the site will not function until I delete my application cookie. I will continue to get the network exception on all page requests. i don't understand how i could be connecting just fine to my database then all of a sudden stop being able to connect to it. Its like a connection to the database went stale and is not able to re-establish.

Any help would be much appreciated.

Thanks

networking
database
web-applications
asked on Server Fault Apr 12, 2020 by Michael Hamling

2 Answers

0

The stack trace indicates that you need to install SQL Server Express and enable the Local Database Runtime feature

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
answered on Server Fault Apr 12, 2020 by Henrik Pingel
0

I have solved my problem. It turns out that the ApplicationDbContext connection string was not set on the Publish settings configuration. I had another dbcontext that was the main one used by the application and it was set. This is why the application work fine at first. There must be something in the Session Time out process that calls into the ApplicationDbContext which caused the exception I was experiencing. Can someone explain what that could be?

answered on Server Fault Apr 12, 2020 by Michael Hamling

User contributions licensed under CC BY-SA 3.0