ASP.Net Prevent Timeout for Long Running Process - asp.net

I have an ASP.net page that uploads a CSV file and then does some processing on it. This can possibly take up to 10 minutes to complete for a large file. However, the process ends up timing out.
I have added the following to the web.config:
<httpRuntime executionTimeout="1200" maxRequestLength="104856" />
Also, I have gone into IIS and set the Connection Timeout to 1,200 seconds. I also set the ASP script timeout to 1,200 seconds in IIS as well.
However, after approximately 2 minutes the web log file stops getting updated.
Any ideas on what is causing this to stop processing? What other timeout settings am I missing?
THanks!

I usually try to avoid long running requests. Are you sure this is the best way to do this? In the past I have either:
Uploaded the document through the web app, but not acted on it. Basically upload it to a watched folder and then process it through a separate process.
Use an alternate method to upload the document (ftp usually). Again, process the file with a separate process.
Probably not the answer you were looking for, but it might be a better solution to your problem?

Related

What exact settings required in iis for asp.net pages to process it faster?

I am having a simple blank page without any source code.The page also taking very long time to come.I am not able to understand the reason behind this.
The domain is getting a high requests.
What exact settings needs to be done in iis 7.0 so that it will be faster.
Please help.
ASP.NET pages always have an initial delay when the first request is made after the file has been created/edited/uploaded because the server needs to recompile them, however it shouldn't be more than 2-3 seconds in practice, and does not affect subsequent pageloads.
The only thing I can think of is an overloaded server. Assuming you're on a shared hosting package then I recommend you find another ISP. If not, then I'm afraid there's a lot more to it than just a "page pages load faster" switch hidden away.

w3wp has handle on download files

I set up iis to handle .exe with "asp.net 2.0"s isapi filter to enable dynamic url replacement.
For this I setup the extension in iis and added the following line to web.config. Works fine so far.
<add path="*.exe" verb="*" type="System.Web.StaticFileHandler" />
the problem is that form that point w3wp process has several handles on these files. Most likely because someone is downloading them at the moment.
Is there a way to tell iis/asp.net not to put a exclusive handle on the file? I want to replace them even if the site is running. This works as long as asp.net does not handle these files.
I don't think there is a way to do this. You are telling IIS to handle this filetype, so the server is assuming a certain exclusivity. This behavior is intended IMO, because it prevents corrupted files in production environment.
Maybe it helps to limit the requests to some selected HTTP verbs (POST/GET), but i don't see any other options.
And the other question is: why do you want to replace a file, that is currently downloaded by a user? It will corrupt his download, forcing him to start all over again.

ASP.NET FileUpload failure

Trying to upload a large file (20MB), I set the maxRequestLength to a high enough level (and the expiration time too) in the httpRuntime entry of web.config. The Event Log stopped reporting that the post size exceeds allowed limits, but I still get the same behavior in the browser (IE or FF): "The connection to the server was reset while the page was loading." I'm using VS2008 and the built-in web server, not IIS. I've read the Q&A on this topic and even put in the check for the exception (IsMaxRequestExceededEexception) in the application global handler. This was referenced in another StackOverflow thread about this topic. Anyone had anything similar, have any ideas?
Thanks,
Bob
Not come accross this myself with the built in server, however you could try increasing the time out too in the web.config file.
<httpRuntime executionTimeout="****" maxRequestLength="****" />
Figured out my problem. I put the entry into the wrong web.config file -- I have two web apps in the same VS solution. doh!
Http uploads are notoriously unreliable. You should look into some other options that utilize Flash or Silverlight for file uploads.

Background File Copy process in ASP

I have an application in classic ASP. On click of a button, it copies a file and its relative folder from one folder to another folder, and displays a link to user for the destination folder. User can click on link and get the file from destination folder. Now, I am facing problem with file and its relative folder size. I have some of them with size greater than 500MB. So, copy process takes so much time that my application gets Time Out error. **Is it possible to create some background process for copy? and when process completes it should fire some event. **
Cheers
This is a pretty lame solution, but a solution nevertheless: you could fire off an Ajax request to a separate ASP script to do the copying, and just put a really long timeout on that script. When this completes, it could, of course, update the calling page with an alert or notification to the user, but that very much depends on the user having enough patience to keep that browser window open.
The options I tried are,
Executing copy command from Shell, not effective because ASP page waits for shell command to finish.
Creating a trigger in SQL database which gets fired when a new row gets added into the table, and then copy the files and send an email to user using TSQL. This affects my overall database performance.
AJAX solution also waits for process to end.
Now the solution I have implemented is, ASP page just creates a request and displays a message to user that user will get an confirmation email, then I created a small windows application which keep on watching for any request generated by ASP page, and as soon as any request comes in, it starts copying the files and at end sends as email to user as confirmation.
This solution is working for my requirements, please do share if you have any better and robust solution for the scenario.
Cheers.
I thought of another idea. I'm not sure of the exact way to do this on an IIS server, but if I were running on a Linux server, I would set up a cron job to run a web script every 5 minutes or so. The script would check for new files and perform the copying. Since copying could take more than 5 minutes, you would probably need to keep track of files in an XML file or db or something.
This would free you from writing/maintaining a separate Windows desktop app.

What is max file upload size in IIS6.0? and how do we overcome that?

In my application, I would like to upload files of size more than 3GB. I increased max file request timeout as high as possible.
But it is not even posting the page to the server when I select a 3GB file.
My web site configuration:
Asp.Net 3.5
IIS 6.0
Is it possible with the above configuration? If not what is the reason, and how do I resolve this?
I'd probably go with a FTP approach. Using FTPWebRequest - try Google for sample code.
You'll need to adjust both the timeout and request length in your web.config appropriately:
<system.web>
<httpRuntime maxRequestLength="102400" executionTimeout="360"/>
</system.web>
Of course keep in mind, a 3Gb file is going to require a lot of patience. In reality, I suggest investigating alternatives - HTTP post is not going to be pretty with files of this size.
One possibility: http://www.banmanpro.com/support2/File_Upload_limits.asp
Unfortunately adjusting the timeout and request length is not going to work. Your web server will run out of memory before the upload completes.
What you need is a file upload control that will break your upload into smaller chunks, so that you don't use all of the server's memory to hold the file while it is uploading.
One of the better file upload controls available is Darren Johnstone's ASP.NET File Upload control. This free control is a drop-in replacement for the standard ASP.NET file upload component, and is specifically designed to handle large files. It even includes a progress bar that doesn't require Flash.
Complete documentation and installation instructions are here:
http://darrenjohnstone.net/aspnet-file-uploaddownload-module-v2-documentation/
The control (and source code) can be downloaded here:
http://darrenjohnstone.net/downloads/

Resources