hosting a pdf file

J

Jesse Aufiero

I want my users to be able to click a link on my asp.net page to open a pdf
document. However, I do not want them to be able to enter in a url that
goes directly to the pdf file, thereby bypassing my log on screen. How can
I achieve this? Where must the pdf file be placed, and with what kind of
security settings?

Thanks!
 
A

Alexey Smirnov

I want my users to be able to click a link on my asp.net page to open a pdf
document.  However, I do not want them to be able to enter in a url that
goes directly to the pdf file, thereby bypassing my log on screen.  How can
I achieve this?  Where must the pdf file be placed, and with what kind of
security settings?

Thanks!

Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment;
filename=filename);
FileStream sourceFile = new FileStream("C:\\PDFs\\" + filename,
FileMode.Open);

long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();

Response.BinaryWrite(getContent);

http://support.microsoft.com/kb/307603/EN-US/
 
J

Jesse.Aufiero

I want my users to be able to click a link on my asp.net page to open a pdf
document. However, I do not want them to be able to enter in a url that
goes directly to the pdf file, thereby bypassing my log on screen. How can
I achieve this? Where must the pdf file be placed, and with what kind of
security settings?

Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment;
filename=filename);
FileStream sourceFile = new FileStream("C:\\PDFs\\" + filename,
FileMode.Open);

long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();

Response.BinaryWrite(getContent);

http://support.microsoft.com/kb/307603/EN-US/



thanks! ...and what event would i hook this into? The goal is to let
the user click a hyperlink to open the pdf...
 
A

Alexey Smirnov

Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment;
filename=filename);
FileStream sourceFile = new FileStream("C:\\PDFs\\" + filename,
FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);

http://support.microsoft.com/kb/307603/EN-US/

thanks!  ...and what event would i hook this into?  The goal is to let
the user click a hyperlink to open the pdf...- Hide quoted text -

- Show quoted text -

Jesse, use the LinkButton control to create a link, and create an
event handler for the Click event

<asp:LinkButton id="LinkButton1"
Text="Download PDF"
OnClick="LinkButton_Click"
runat="server"/>

in the code-behind

void LinkButton_Click(Object sender, EventArgs e)
{
....
}
 
J

Jesse.Aufiero

I want my users to be able to click a link on my asp.net page to open a pdf
document. However, I do not want them to be able to enter in a url that
goes directly to the pdf file, thereby bypassing my log on screen. How can
I achieve this? Where must the pdf file be placed, and with what kind of
security settings?
Thanks!
Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment;
filename=filename);
FileStream sourceFile = new FileStream("C:\\PDFs\\" + filename,
FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
http://support.microsoft.com/kb/307603/EN-US/
thanks! ...and what event would i hook this into? The goal is to let
the user click a hyperlink to open the pdf...- Hide quoted text -
- Show quoted text -

Jesse, use the LinkButton control to create a link, and create an
event handler for the Click event

<asp:LinkButton id="LinkButton1"
Text="Download PDF"
OnClick="LinkButton_Click"
runat="server"/>

in the code-behind

void LinkButton_Click(Object sender, EventArgs e)
{
....

}

if you are interested in consulting, i have a small project that i
could use some assistance with. let me know if you are interested:
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top