Opening a Pdf document in Adobe photoshop - asp.net

I have a silverlight control to upload documents in my web page to share point. While I upload a document it is successfully uploaded. But when i try to open it by clicking on the document the pdf document uploaded opens in the redirected IE page.
I want that Pdf to be directly opened in Adobe Reader instead of redirecting it to open in an IE page.
Can anyone please suggest if this is a browser setting or I need some code for it?
Thanks
Yogesh

Response.Clear();
Response.ContentType = "application/pdf";
OBJ.Save(Response.OutputStream, File);
Response.AddHeader("content-disposition", "attachment;filename="
+ "abcd".ToString());
Response.Flush();
Response.End();
Above is the code for downloading it. If you are saving the file in DB then get the binary data or if you are saving it in a folder within your app, give the path.

Related

Save file opened with navigateToURL

I'm using navigateToURL to open a PDF file generated by Jasper and it's working well. Now I was asked to send an email with the PDF file as an attachment. We are using Velocity to send emails in our application but, to send attachments, we have to have the file saved somewhere and have the info of the path and filename.
Is it possible to save to file opened by navigateToURL?
I'm using Flex SDK 4.9.1.
Thank you.
Are you using JasperExportManager.exportReportToPdfStream() method to show the PDF?
If so, try to use JasperExportManager.exportReportToPdfFile().
Then you can save the PDF at server.
JasperPrint jasperprint = JasperFillManager.fillReport(jasper, paramMap, con);
// Streaming pdf now?
response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperprint, response.getOutputStream());
// Save the PDF somewhere.
JasperExportManager.exportReportToPdfFile(jasperprint, path);

Download a file on the client macine using asp.net

I want to download a text file from my website to the users pc without prompting him for the location to save the file.
I have tried it using code below :
Response.TransmitFile("G:\Medical Reporting\Medical\Users\Vishal\Uploaded\Key.txt")
Response.End()
But every time I am just redirected to the new page and all the contents of the file is written there. I don't want to display the contents of the file, but I want to download the file.
Not possible - it's a security issue, otherwise the world would be trying to save all sorts of files on a users machine.
If it's an intranet each user could have a shared drive on a network accessible to the web app and simply copy the file using IO.File.Copy method.
Update
To Prompt a user to download a file you can use the following code which will be fired after clicking something like a button:
this example is for an image, though you can just change the ContentType filename to suit your needs.
Response.ContentType = "image/jpeg";
// this is the important bit that gives the user the prompt to save
Response.AppendHeader("Content-Disposition","attachment; filename=yourfile.jpg");
Response.TransmitFile(Server.MapPath("~/yourfile.jpg"));
Response.End();

Hide Downloadlink ASP

i'am trying to hide the Downloadlink from some files. They're on a FTP. When i download a file then i can backtrack to the server and crawl some more files but i want to prevent that. I've already searched some solutions but i never got them working.
I have a seperate download.ashx File with th following code. I't a example for only the file download.zip
Response.Clear()
Response.ContentType = "application/x-zip-compressed"
Response.AppendHeader("Content-Disposition", "attachment; filename=download.zip")
Response.WriteFile(ftp://server.de/files/scripts/files/)
Response.End()
This is the Hyperlink for the download
Click here to Download File
Everytime when I click the downloadlink i get a Runtime Error:
Server Error in '/files/scripts/files' Application.
I hope you've some ideas to solve this problem.
Thanks
Have a look at this answer ASP.NET Create zip file for download: the compressed zipped folder is invalid or corrupted
If you can get the download code working you can hide the file location by generating (for example) an asp button that points to the download, rather than a link to the FTP.

Asp.net - Prevent file (PDF, Word) download from a particular folder

I am creating a recruitment site and have a folder called /CV/ where I am storing resume files uploaded by the member.
Lets say a user saves their resume and its called 123.pdf and is stored in cv/123.pdf.
How can I prevent the pdf file from loading in the browser window or downloading to the users machine if they type in 'http://mydomain.com/cv/123.pdf'?
I am using forms Authentication, Asp.Net Membership and Roles Providers, Asp.net 4 on an IIS6 server.
Create a folder that is outside of the hierarchy of the main www folder used by the site (so it cannot be directly accessed through url)
Use an ashx handler to provide access to download the file. The logic within the ashx file can validate whether the user is authorized to download the file or not.
ASHX references: 1, 2, 3
The best way would be to put the files somewhere else, and write some code to access them -- then that code can verify whether the caller has the necessary rights.
For instance, you may store files in your /uploads/xyz123/ directory. Then in order to download a file, say myresume.pdf, the user would have to surf to http://yourserver/download.aspx?file=myresume.pdf.
That page then does the necessary validations, loads the file and outputs it as a binary to the browser, like so:
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
Response.AddHeader("content-length", binaryStream.Length.ToString);
Response.BinaryWrite(binaryStream.ToArray());
Response.Flush();
Response.End();
No user will ever find out where the files are actually stored.
You can simple save the file in a directory that is not part of your web application.
If you want to store a file that should not be reached via http, do it this way.

How to get a file from a Database and put it in an FTP?

I have an aspx page that gets a list of documents available in a database through a DataGridview and I want that when the users clicks on the link of the document he want's to sent it as an FTP or HTTP document, like if it was on a drive on the server.
The problema I have is that I know that when the file is on a drive it is easy but if it is on the database I do not know how to serve it to the web page user.
I thougth maybe that when de user clicks on the link to save the file to a temp directory, and then redirect the page to that page with the name of the file, but I do not know if it is to much of a touble and there is a better way. Of course if I do this I will have to delete the file from the drive after it has been downloaded.
I get the way to do this, is just a matter of use
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition", "attachment; filename=SailBig.jpg");
//Response.BinaryWrite(foto);
Response.OutputStream.Write(foto, 0, foto.Length);
The file, is in binary.

Resources