|
-
Oct 29th, 2008, 12:34 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Getting the following error randomly on my .aspx that involves javascript and AJAX. It seems to be happening if I don't run the process on the page for 10-15 minutes. After I get one time out it usually works the next try and increasingly gets faster every time after that until it sits idle again.
This page is using a pretty simple stored proc to populate a gridview that is inside an updatepanel.
I get a popup box with the following error:
Sys.WebForms.pageRequestManager TimeoutException : the server request timed out
Code:
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Cust_CM.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>A/R Credit Memos</title>
<link href="StyleA.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" Height="50px" Style="text-align: right" Width="608px">
<div style="float: left; width: 200px; height: 100px; text-align: left">
<br />
<asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Size="Larger" Text="Credit Memos"
Width="192px"></asp:Label><br />
</div>
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="400px" style="text-align: left">
<br />
<br />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Generating Data...<br />
<img src="pleasewait.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Panel>
</asp:Panel>
<br />
<br />
<table style="width: 576px" >
<tr>
<td style="width: 114px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Invoice Date:" Width="96px"></asp:Label></td>
<td style="width: 175px">
<asp:TextBox ID="txtInvoiceDateFrom" runat="server" Width="96px"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtInvoiceDateFrom">
</cc1:CalendarExtender>
</td>
<td style="width: 15px">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="To"></asp:Label></td>
<td>
<asp:TextBox ID="txtInvoiceDateTo" runat="server" Width="96px"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtInvoiceDateTo">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td style="width: 114px">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Project Number" Width="112px"></asp:Label></td>
<td colspan="2">
<asp:TextBox ID="txtProjectNumber" runat="server"></asp:TextBox></td>
<td>
<asp:Button ID="btnShow" runat="server" Text="Show Report" OnClick="btnShow_Click" /></td>
</tr>
</table>
<asp:Label ID="lblError" runat="server" ForeColor="Red" Width="576px"></asp:Label><br />
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False" EmptyDataText="There were no results to your query.">
<Columns>
<asp:BoundField DataField="MainProject" HeaderText="Project" />
<asp:BoundField DataField="BillTask" HeaderText="Task" />
<asp:BoundField DataField="invoice" HeaderText="Invoice No" />
<asp:BoundField DataField="InvoiceDate" DataFormatString="{0:d}" HeaderText="Invoice Dt"
HtmlEncode="False" />
<asp:BoundField DataField="Description" HeaderText="Description" HtmlEncode="False" />
<asp:BoundField DataField="footer" HeaderText="Footer" HtmlEncode="False" />
</Columns>
<RowStyle BackColor="#E0E0E0" />
<HeaderStyle BackColor="Silver" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler)
function BeginRequestHandler(sender, args)
{
var btn = document.getElementById("<%= btnShow.ClientID %>");
btn.disabled = true;
var txt1 = document.getElementById("<% = txtInvoiceDateFrom.ClientID %>");
txt1.disabled = true;
txt1 = document.getElementById("<% = txtInvoiceDateTo.ClientID %>");
txt1.disabled = true;
txt1 = document.getElementById("<% = txtProjectNumber.ClientID %>");
txt1.disabled = true;
return false;
}
function EndRequestHandler(sender, args)
{
var btn = document.getElementById("<%= btnShow.ClientID %>");
btn.disabled = false;
var txt1 = document.getElementById("<% = txtInvoiceDateFrom.ClientID %>");
txt1.disabled = false;
txt1 = document.getElementById("<% = txtInvoiceDateTo.ClientID %>");
txt1.disabled = false;
txt1 = document.getElementById("<% = txtProjectNumber.ClientID %>");
txt1.disabled = false;
return false;
}
</script>
</html>
vb Code:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Sub BindGrid()
Dim cmd As New XSQL("XXXXX", 2)
Try
cmd.AddStrParam("@Project", txtProjectNumber.Text, 20)
cmd.AddStrParam("@StDate", txtInvoiceDateFrom.Text, 10)
cmd.AddStrParam("@EndDate", txtInvoiceDateTo.Text, 10)
gvResults.DataSource = cmd.ExecuteDS("USP_GetCreditMemos")
gvResults.DataBind()
lblError.Text = ""
Catch ex As Exception
lblError.Text = ex.Message
End Try
End Sub
Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If txtProjectNumber.Text = "" Then
If txtInvoiceDateFrom.Text <> "" And txtInvoiceDateTo.Text <> "" Then
BindGrid()
Else
Show("You must enter a Project Number if you are not using a date range.")
End If
Else
BindGrid()
End If
End Sub
Private Sub Show(ByVal message As String)
Dim strScript As String
strScript = "<script type='text/javascript' language='javascript'>"
strScript = strScript & "alert('" & message & "');"
strScript = strScript & "</script>"
ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "alert", strScript, False)
End Sub
End Class
-
Oct 30th, 2008, 01:43 AM
#2
Fanatic Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
You are missing the connection. At least i couldn't see the declaration of the connection nor opening the same object. Maybe you want to switch to regular debug and see the exception source?
-
Oct 30th, 2008, 05:25 AM
#3
Thread Starter
Frenzied Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
the connection is in the XSQL class. What do you mean by regular debug?
-
Oct 30th, 2008, 05:50 AM
#4
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Second post here?
http://www.dotnet-friends.com/Forum/...00&ThreadNew=0
Although it's a workaround rather than the real problem... is it attempting to repopulate the grid every x seconds?
-
Oct 30th, 2008, 06:40 AM
#5
Thread Starter
Frenzied Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Yeah I saw that post upon my searches. If I do extend the timeout period I won't get the error and the grid will populate eventually. The thing is that this is a very simple page and simple stored proc consisting of one select statement. And as I mentioned in post #1 that it gets faster every time after it times out. This only occurs after it's been idle for a while. I've tried removing the javascript also because I am pretty noob when it comes to straight javascript and it had no affect.
This is my XSQL class if anyone thinks there is something in there that might be causing this to happen.
vb Code:
Imports System.Data.SqlClient
Imports System
Imports System.Data
Public Class XSQL
Private rows As Int32, cols As Int16, retVal As Int64
Protected adoCon As New SqlConnection()
Protected adoCmd As New SqlCommand()
Protected adoDR As SqlDataReader 'if the user needs a data reader
Protected adoDA As New SqlDataAdapter() 'if the user needs a data set
Protected adoDS As New DataSet() 'if the user needs a data set
Private myTrans As SqlTransaction
Public Shared Function getConnString(ByVal AppId As String) As String
Dim userId As String = "XXXXX"
Dim pwd As String = "XXXXX"
Dim connStr1 As String
Dim connStr2 As String = "uid=" & userId & ";password=" & pwd & ";Connect Timeout=30"
Select Case AppId
Case "XXXXX"
connStr1 = "server=XXXXX;database=XXXXX;"
End Select
Return (connStr1 & connStr2)
End Function
Public Sub BeginTran()
myTrans = adoCon.BeginTransaction(IsolationLevel.ReadCommitted, "xTran")
adoCmd.Transaction = myTrans
End Sub
Public Sub CommitTran()
myTrans.Commit()
End Sub
Public Sub RollbackTran()
myTrans.Rollback("xTran")
End Sub
Sub New(ByVal AppId As String, Optional ByVal cmdType As Integer = 1, Optional ByVal rsType As Integer = 1)
'cmdType 1 = sqlcommand; cmdType 2 = stored procedure
'rsType 1 returns DataReader; rsType 2 returns dataset
adoCon.ConnectionString = getConnString(AppId)
If cmdType = 2 Then
adoCmd.CommandType = CommandType.StoredProcedure
Else
adoCmd.CommandType = CommandType.Text
End If
adoCmd.CommandTimeout = 120
adoCmd.Connection = adoCon
'if returning a dataset, dont ve to open the connection; the sqldataAdapter takes care of it
'open the connection only if returning dataReader
If rsType = 1 Then
adoCon.Open()
End If
End Sub
Public Sub AddDateParam(ByVal pName As String, ByVal pValue As DateTime)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.DateTime)
myParm.Value = pValue
End Sub
Public Sub AddSmallDateParam(ByVal pName As String, ByVal pValue As DateTime)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.SmallDateTime)
myParm.Value = pValue
End Sub
Public Sub AddIntParam(ByVal pName As String, ByVal pValue As Integer)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.Int)
myParm.Value = pValue
End Sub
Public Sub AddBitParam(ByVal pName As String, ByVal pValue As Boolean)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.Bit)
myParm.Value = pValue
End Sub
Public Sub AddStrParam(ByVal pName As String, ByVal pValue As String, ByVal pLen As Integer)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.NVarChar, pLen)
myParm.Value = pValue
End Sub
Public Sub AddIntOutParam(ByVal pName As String)
Dim myParm As SqlParameter = adoCmd.Parameters.Add(pName, SqlDbType.Int)
myParm.Direction = ParameterDirection.Output
End Sub
Public Sub ClearCmdParam()
adoCmd.Parameters.Clear()
End Sub
'DataReader - execute query that returns rows
Public Function ExecuteQ(ByVal cmdTxt As String) As SqlDataReader
adoCmd.CommandText = cmdTxt
adoDR = adoCmd.ExecuteReader
ExecuteQ = adoDR
End Function
'DataReader - execute sql (non query) that does not return rows
Public Function ExecuteNQ(ByVal cmdTxt As String) As Integer
adoCmd.CommandText = cmdTxt
rows = adoCmd.ExecuteNonQuery
ExecuteNQ = rows
End Function
'DataReader - execute scalar query - returns 1 value
Public Function ExecuteSc(ByVal cmdTxt As String) As Object
adoCmd.CommandText = cmdTxt
ExecuteSc = adoCmd.ExecuteScalar
End Function
'DataSet - execute query that returns a data set
Public Function ExecuteDS(ByVal cmdTxt As String) As DataSet
adoCmd.CommandText = cmdTxt
adoDA.SelectCommand = adoCmd
adoDA.Fill(adoDS, "SQLDS")
rows = adoDS.Tables(0).Rows.Count
cols = adoDS.Tables(0).Columns.Count
ExecuteDS = adoDS
End Function
'Insert performing an insert and retrieving 1 output parameter
Public Function InsertWithReturn(ByVal cmdTxt As String, ByVal pName As String) As Integer
adoCmd.CommandText = cmdTxt
adoCmd.ExecuteNonQuery()
InsertWithReturn = Convert.ToInt32(adoCmd.Parameters(pName).Value)
End Function
Public Sub CleanUp()
If Not adoDR Is Nothing Then
If Not adoDR.IsClosed Then
adoDR.Close()
End If
End If
adoCon.Close()
adoDA = Nothing
adoDS = Nothing
adoDR = Nothing
adoCon = Nothing
adoCmd = Nothing
End Sub
End Class
-
Oct 30th, 2008, 09:57 AM
#6
Fanatic Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Please check this article, you might find it useful.
Also as mentioned you should configure the Application for debugging.
To enable debugging, add a compilation element to the site's root Web.config file, and then set its debug attribute to true.
vb Code:
<configuration> <system.web> <compilation debug="true"> <!-- etc. --> </compilation> </system.web> <configuration>
-
Oct 30th, 2008, 10:11 AM
#7
Thread Starter
Frenzied Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Yeah my debug was always set to true.... looked at the msdn link, didn't really address my problem. Right now I have the timeout set to 96000 so I don't receive an error, but sometimes it will take almost 3 full minutes for my page to display 5 records.
-
Oct 30th, 2008, 01:42 PM
#8
Thread Starter
Frenzied Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
scratch my previous post... even after setting the timeout of the scriptmanager to 96000 I got an error in my serverside code now...
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
-
Oct 30th, 2008, 02:35 PM
#9
Thread Starter
Frenzied Member
Re: [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Ok well, I am thinking it is the stored proc now... I took all of the AJAX out and ran it on a plain aspx page and it seems to be having the same behavour. So it's either the proc or the connection to the db.
Gonna mark this resolved as it doesn't seem to be anything to do with ASP.NET. :P
-
Oct 30th, 2008, 05:47 PM
#10
Fanatic Member
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
If you add some Try Catch statements to the XSQL class you should get the precise indicators for the exception. i.e. missing parameter or such. Try Catch into the BindGrid() Sub is actually pretty useless in your situation.
Regards
-
Oct 31st, 2008, 10:25 AM
#11
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
OK, so if you've narrowed it down to the DB, then what does the SP look like? We could help with that too.
-
Oct 31st, 2008, 10:29 AM
#12
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
Code:
CREATE PROC USP_GetCM
@Project VARCHAR(20),
@StDate DATETIME,
@EndDate DATETIME
AS
BEGIN
If @Project = '' Or @Project IS NULL
SELECT @Project = "%"
If @Stdate IS NULL
SELECT @Stdate = "1900-01-01"
If @Enddate IS NULL or @Enddate = "1900-01-01"
SELECT @Enddate = GETDATE()
SELECT MainProject, BillTask, invoice, InvoiceDate, Description, footer
FROM CMTable
WHERE InvoiceDate BETWEEN @Stdate AND @Enddate
AND MainProject LIKE @Project
AND invoice <> "<Draft>"
AND
( Description like '%credit%'
OR description like '%applied%'
OR description like '%apply%'
--OR description like '%inv%'
OR footer like '%credit%'
OR footer like '%applied%'
OR footer like '%apply%'
--OR footer like '%inv%'
)
ORDER BY MainProject, BillTask, invoice
END
GO
-
Oct 31st, 2008, 11:02 AM
#13
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
I think the problem might be with all the LIKE clauses in there. Try taking the SELECT and the FROM together with just the invoicedate clause to see how long that takes. You can also do Ctrl+L to see the execution plan and what's taking the most time/processing cycles.
Why are you having to perform so many likes on the description? If they are going to be one of four specific text fields, then you should make them int fields and map the ints to another table that contains those values. In other words, it's like an enumeration.
-
Oct 31st, 2008, 11:52 AM
#14
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
I am not even familiar with the actual DB that this is querying. The proc was made by a previous developer, I was just told to make a new interface for it. If it is the stored proc, wouldn't the performance be the same everytime it's run? As of now it gets better and better each time.
-
Nov 1st, 2008, 04:27 AM
#15
Re: [RESOLVED] [2005] Sys.WebForms.pageRequestManager TimeoutException : the server request timed ou
The execution plan gets cached so it should get faster compared to the first time. But if you're experiencing a timeout, there must be something in the SP that's causing it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|