473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Timeout expired error after adding download file code

If I add the code for user to download the file (e.g.
if(File.Exists(FILE_NAME)){......}), the ASP.NET will give the
following timeout error:

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

It seems that the download file code is executing before letting the
previous code to finish. Even the message print code
(message.Text="...";) is not executed.

What could I do to eliminate this problem. These are the codes for my
ASP.NET application.

private void run_Click(object sender, System.EventArgs e)
{
message.Text="";
bool alert=false;
string connectionString =
ConfigurationSettings.AppSettings["connString"];
SqlConnection connection = new SqlConnection(connectionString);
if(option.SelectedValue.ToString()=="C")
{
SqlCommand command = new
SqlCommand("inletter3_uterm",connection);
command.Connection=connection;
command.CommandType=CommandType.StoredProcedure;
command.CommandText = "inletter3_uterm";
.........
connection.Open();
command.ExecuteNonQuery();
connection.Close();
string commandString ="select
rtrim(ref)+'/CEM/Rfd/'+rtrim(user_dept_no)+'/'+substring(convert(char,sel_date,112),3,4)
as ref_val,"+
"rtrim(convert(char,DATENAME(month, iss_date)))+'
'+rtrim(convert(char,day(iss_date)))+',
'+rtrim(convert(char,year(iss_date))) as iss_date,"+
"rtrim(D.title) as title from iv_letter3 L, iv_dept D where
L.user_dept_no = D.dept_no";

SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString,
connectionString);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
DataTable dt = ds.Tables[0];

string FILE_NAME=@"c:\inventry\doc\inlet3ut.txt";
StreamWriter sw = new StreamWriter(FILE_NAME, false,
System.Text.Encoding.ASCII);
foreach (DataRow dataRow in dt.Rows)
{
sw.WriteLine("#"+dataRow["ref_val"].ToString().Trim());
sw.WriteLine(dataRow["iss_date"].ToString().Trim());
sw.WriteLine(dataRow["title"].ToString().Trim());
}
sw.WriteLine("#");
sw.Close();

if(updatedate.Checked==true)
{
SqlCommand command2 = new
SqlCommand("inutmti_upd",connection);
command2.Connection=connection;
command2.CommandType=CommandType.StoredProcedure;
command2.CommandText = "inutmti_upd";
.................
connection.Open();
command2.ExecuteNonQuery();
connection.Close();
}
message.Text="User Termination/Obsolete Letter successful
printed to a file\n";
//if such codes are commented, there is not timeout expired
error
if(File.Exists(FILE_NAME))
{
FileInfo myFileInfo = new FileInfo(FILE_NAME);
String filename = Path.GetFileName(FILE_NAME);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition","attachment;
filename=\"" + filename + "\"");
Response.AddHeader("Content-Length",
myFileInfo.Length.ToString());
Response.Flush();
Response.WriteFile(FILE_NAME);
Response.End();
Response.Close();
}
//end of codes giving timeout expired error
}
}

Feb 28 '06 #1
0 2005

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vincento Harris | last post by:
sql server 2000 8.00.194 Microsoft Windows 2000 Service Pack 2 I looked into my sqlserver agent log and found the following ODBC Error 0 Timeout expired logon to server local '( failed)' ...
0
by: Silvia | last post by:
I have a application web and when execute this for a long time generated this error: Server Error in '/RAIMServer' Application. -----------------------------------------------------------...
5
by: Jason | last post by:
Hi all I get the following error when executing a rather intense stored procedure from an ASPX page. I have tried: - Increasing timeouts on IIS 5.0 (all areas that even mention timeout) - use...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
4
by: Nevyn Twyll | last post by:
I've been working on an asp.net application and everything's been great. But suddenly, whether I'm tyring to use a database on my own machine, or on my server, I'm getting a timeout when trying to...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
3
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection...
1
by: Scorpion657 | last post by:
Hey I really need help. I have a Website coded using ASP.NET and VB and for some reason, i'm getting the following error when I try to upload or access a large file which is stored in the...
2
by: Andrew Cooper | last post by:
Greetings, I've got a website that has several pages with DataGrid controls on them. The controls are bound to Object Datasources. On one of the pages I keep getting a "Timeout expired. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.