HttpUnhandledException ASP.NET

I have an ASP.NET site. If I make a page request, it works most of the time, but sometimes I get an HttpUnhandledException.

I tried to register errors, but from the error messages I can not solve the problem.

Stacktrace:

at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\4e215a3c\72ef69da\App_Web_ylvnbciw.6.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Data:

System.Collections.ListDictionaryInternal

BaseException:

System.InvalidOperationException: The connection was not closed. The connection current state is open.
   at DbCategory.getParentCategories()
   at _Default.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

TargetSite:

Boolean HandleError(System.Exception)

I have an idea that this is something about my og session that gets the variables, but I'm not sure about that. Does anyone have any idea what this might be?

+3
source share
3 answers

Such errors are not due to an incorrect order - the connection was not closed.

, SqlConnection , , - .


: , - , - , . SqlConnection - , .

- , .

, singleton, :

private static object singleton;

lock (singleton)
{
    // Some manipulations with your server
}
+1

Db (DbConnection, DbCommand, , ..) " ".

- 99% , , , .

+1

VMAtm: , - , , . singleton...

public static SqlConnection getDbConnection() 
{ 
    if (sqlConn == null) 
    { 
        source = "data source=..."; 
        sqlConn = new SqlConnection(source); 
    }
    return sqlConn; 
}

?

, db singleton

0

Source: https://habr.com/ru/post/1741972/


All Articles