简体   繁体   中英

SQL Server Exception:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

I have created a login page in asp.net and created a user and role in asp.net membership, after login I have a query in my page load method to check the role of user and display a view of the page as per that user but I am getting this error.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

My code:

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.User.Identity.IsAuthenticated)
    {

        if (Roles.IsUserInRole("Manager"))
        {

            NavigationMenu.Visible = false;
            NavigateMenu1.Visible = true;

                creategrid();
        }
    }
}

This exception only occurs as I run my application for the first time and as I refresh page try to login again then there is no exceptions. please help me as I am new this.

The error message is trying to say that, its taking longer time to establish a connection than the default timeout period..

Though you can increase the timeout, I would suggest you not do it..

find out why its happening.. If its happening frequently, then may be your connection pool may not be having sufficient connections at that time..if so, you can increase the min pool size or max pool size and have reasonable Connection Lifetime, etc.,

see http://msdn.microsoft.com/en-us/library/8xx3tyca(v=vs.71).aspx

在命令对象中设置commandTmeout属性。

cmd.CommandTimeout = 9000;

Add timeout of your SqlCommand . Please add time is in second .

// Setting command timeout to 1 second
 cmd.CommandTimeout = 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding with Azure SQL database Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding ExecuteQueryin linq :Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Linq Count() timing out -Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Execute package in ssis causes Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. working on remote windows .net Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding C# entityframework core throwing Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM