Solved

Web Server CleanUp Question

Posted on 2012-03-23
4
175 Views
Last Modified: 2012-03-26
This may sound like the dumbest question...but I'm NEW to Web Developement and ASP.net.

I've recently begun creating PDF using iTextSharp and if I write to the server and then use Window.Open to display it after the user does what ever they want with it (save, print, etc.) how do I get rid of it on the server so these files don't keep building up?

I tried to display the PDF using Window.Open and then delete the file on page unload but it appears that it deletes it before displaying it, so how do I know when the user is done with the file so I can remove it from the server?

OR

If I create the file using Response.Write...how can I open the file automatically instead of displaying the dialog box that gives the user the option to Open, Save or Cancel?  I wouldn't mind using Response.Write if I could automatically open the file on completion.

Thanks,
Mark
0
Comment
Question by:smithmrk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
gery128 earned 500 total points
ID: 37757058
You can do one thing, once your user request for a file, before generating the file you should loop through the directory (where you save your file) and delete all files using IO namespace. So after that you generate one file which will be deleted on subsequent request from the users. That will make sure you will have only one file at a time on server.

Or if you want directly transfer file to response it can be done (assuming the user has Adobe Reader or any other PDF reader plugin installed on browser) by adding special lines to headers:
see this links:
http://stackoverflow.com/questions/3861395/asp-net-show-pdf-file-to-user-instead-of-save-as-dialog
http://forums.asp.net/t/1668481.aspx/3/10?Open+any+file+INSIDE+a+browser+without+open+save+dialog+
0
 

Author Comment

by:smithmrk
ID: 37757428
Your first link (Stackoverflow) doesn't work...but let me review the other one and I'll get back to you.

Thanks,
Mark
0
 
LVL 9

Expert Comment

by:gery128
ID: 37759061
0
 

Author Closing Comment

by:smithmrk
ID: 37767611
Not sure which way I'm going to go, but thanks for the advice!

Mark
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question