Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hosting a pdf file

0 views
Skip to first unread message

Jesse Aufiero

unread,
Apr 15, 2008, 1:19:45 PM4/15/08
to
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!


Alexey Smirnov

unread,
Apr 15, 2008, 2:04:41 PM4/15/08
to

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/

Jesse....@gmail.com

unread,
Apr 15, 2008, 2:49:41 PM4/15/08
to

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

Alexey Smirnov

unread,
Apr 15, 2008, 4:46:18 PM4/15/08
to
> 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)
{
....
}

Jesse....@gmail.com

unread,
Apr 15, 2008, 8:27:18 PM4/15/08
to

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:
jesse....@gmail.com

0 new messages