472,328 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 1922

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...
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...
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...

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.