473,888 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(objec t sender, System.EventArg s e)
message.Text="" ;
bool alert=false;
string connectionStrin g =
ConfigurationSe ttings.AppSetti ngs["connString "];
SqlConnection connection = new SqlConnection(c onnectionString );
if(option.Selec tedValue.ToStri ng()=="C")
SqlCommand command = new
SqlCommand("inl etter3_uterm",c onnection);
command.Connect ion=connection;
command.Command Type=CommandTyp e.StoredProcedu re;
command.Command Text = "inletter3_uter m";
connection.Open ();
command.Execute NonQuery();
connection.Clos e();
string commandString ="select
rtrim(ref)+'/CEM/Rfd/'+rtrim(user_de pt_no)+'/'+substring(con vert(char,sel_d ate,112),3,4)
as ref_val,"+
"rtrim(convert( char,DATENAME(m onth, iss_date)))+'
'+rtrim(convert (char,day(iss_d ate)))+',
'+rtrim(convert (char,year(iss_ date))) as iss_date,"+
"rtrim(D.ti tle) as title from iv_letter3 L, iv_dept D where
L.user_dept_no = D.dept_no";

SqlDataAdapter dataAdapter = new SqlDataAdapter( commandString,
connectionStrin g);
DataSet ds = new DataSet();
dataAdapter.Fil l(ds);
DataTable dt = ds.Tables[0];

string FILE_NAME=@"c:\ inventry\doc\in let3ut.txt";
StreamWriter sw = new StreamWriter(FI LE_NAME, false,
System.Text.Enc oding.ASCII);
foreach (DataRow dataRow in dt.Rows)
sw.WriteLine("# "+dataRow["ref_val"].ToString().Tri m());
sw.WriteLine(da taRow["iss_date"].ToString().Tri m());
sw.WriteLine(da taRow["title"].ToString().Tri m());
sw.WriteLine("# ");

if(updatedate.C hecked==true)
SqlCommand command2 = new
SqlCommand("inu tmti_upd",conne ction);
command2.Connec tion=connection ;
command2.Comman dType=CommandTy pe.StoredProced ure;
command2.Comman dText = "inutmti_up d";
............... ..
connection.Open ();
command2.Execut eNonQuery();
connection.Clos e();
message.Text="U ser Termination/Obsolete Letter successful
printed to a file\n";
//if such codes are commented, there is not timeout expired
if(File.Exists( FILE_NAME))
FileInfo myFileInfo = new FileInfo(FILE_N AME);
String filename = Path.GetFileNam e(FILE_NAME);
Response.Clear( );
Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition","a ttachment;
filename=\"" + filename + "\"");
Response.AddHea der("Content-Length",
myFileInfo.Leng th.ToString());
Response.Flush( );
Response.WriteF ile(FILE_NAME);
Response.Close( );
//end of codes giving timeout expired error

Feb 28 '06 #1
0 2042

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

Similar topics

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)' (Job manager) I have no idea what that means but it did keep out users for a minute or more. The threads found on this forum almost all point to reccuring situations
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. ----------------------------------------------------------- --------------------- Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and
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 the "Connection Timeout=2400" string in the SqlConnection connections string - disabled connection pooling.
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 Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
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 open a database connection. The error seems to happen regardless of what ASP.NET app I'm working with/trying to debug. It will open a few connections, Here's the error:
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
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 connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
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 database. It was working fine when I was runing the site on the localhost. I added the following line to the web.config file to increase the timeout: <httpRuntime maxRequestLength="1048576" executionTimeout="3600"/> I also added: connection timeout =...
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 timeout period elapsed prior to completion of the operation or the server is not responding." error. The data is being filled from a Stored Procedure on an SQL Server. When I run the Stored Procedure on the actual server, it is only taking 24...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.