What is the functionality
This web application allows user to upload to web-server, download and delete files uploaded on web-server.
Problem
After downloading a file, when user tries to delete it, an exception is thrown saying this file is being used by another process.
What can be done after download is complete so that IIS releases any lock on the file?
Are you using Server.TransferFile to serve the file from the server? Or you might have something setup in your handlers that causes a similar method to send the files.. The only thing I've seen to unlock the file is to reset IIS :-/
Instead of letting IIS serve the file if you let asp.net send it back in the Response stream then you shouldn't get a problem with the file being locked
also make sure you're disposing of any STream readers that are accessing the files..
If that doesn't help then please post code :-)
Related
Currently, in order to push my website live I upload files to the server via FTP using FileZilla. If a user reloads the site when I'm pushing over the website DLL, they'll get a File is being used by another process type of error.
Are there any better pushover techniques I can make use of to get around this issue or any techniques that are generally better than using at FTP client to upload my site?
You can always upload an app_offline.htm file while you are deploying the new site. If you do this in an asp.net application the user will be directed to the app_offline.html file no matter what page they try to load/reload. When you're ready for them to access the site again you simply remove/delete/rename the file (i usually just rename it so it's a simple rename to get the site back into offline mode).
http://weblogs.asp.net/dotnetstories/archive/2011/09/24/take-an-asp-net-application-offline.aspx
Everytime I Type in the exact path to my file I can play it even without being logged in. I want to make it where I have the files in my computer (not in a database in the computer or someone else's) I log in and I can download them from whatever computer I logged in to my site with. Direct path I want to be redirected or not available to let download. Only those logged in can download... even if everyone knows the path to the file. Possible? Appreciate your help!!!
Create an HttpModule and on the BeginRequest method check if the request is being made to a file you need to protect, if so, return a 403 https status code.
I currently have a asp.net site that allows users to upload files and subsequently view them using HTTP. Is there a simple way to prevent a user from uploading a malicious script/file onto my server then attempting to run that script by calling its directory via http?
You have to remove the ASP script mapping on that particular folder.
Read the complete answer by Steve Schofield here.
I'm developing a Web application, and there is a page when user must submit files which are saved into temporary folder on the server. If everything goes well, I send ajax request to the server to remove users uploaded file. But, if user closes the browser or shutdown the computer, I can't detect that.
In this case, what is the best way to gurantee that unused files are not stored forever? The site is developed in ASP.NET MVC and will be hosted on II7. Does IIS7 provides some configuration to deal with temporary files? Or I need to implement some service, which will be executed in a background with low priority and periodically check if there are "old" files to be removed?
Any help is very much appreciated.
I would have a windows service in the background to delete old files at some interval.
I created a file browser control which open files on client machine itself, so I don't need to bother about file path
from my application I am not able to redirect page to
file:///C:/Program%20Files/Application/readme.txt
it works for
http://
how can I configure my application to support file handler.
Thanx
If you are trying to redirect to a local file. This is not possible without knowing quite a lot of information on the client machine - for example how do you know the directory structure of the client computer?
Response.Redirect tells the client (browser) where to redirect to. A file URL will be one that is on the client machine - you would need to know in advance that the file is there, that the user has permissions to view it etc...
Are you asking how to send a file from the server?
You can do this via Response.WriteFile.