Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > can't open pdf file from aspx page

Reply
Thread Tools

can't open pdf file from aspx page

 
 
graphicsxp
Guest
Posts: n/a
 
      05-31-2006
Hi,
I have the following:
Dim p As String = Server.MapPath("~/Uploads/pdf/test.pdf")
Response.Redirect(p)

The value of p is correct and the file exists. If I enter manually the
value of p into my browser address bar, then the pdf file is properly
opened.

However from the code it doesn't work and although I've added a try
catch block I still can't see the exception. It says:


An exception of type 'System.Exception' occurred in myProject.DLL but
was not handled in user code.

I'm a bit lost there. Can you help ?
Thanks

 
Reply With Quote
 
 
 
 
Ray Booysen
Guest
Posts: n/a
 
      05-31-2006
Copied and pasted from a previous post by Karl:

Response.Redirect throws a ThreadAbordException
intentionally. Technically, Response.Redirect calls Response.End() which
throws the exception.

If you specify true as a 2nd parameter (by default it's false),
Response.End() isn't called, and the page is fully processed before being
redirected.

The real solution to your problem is not to swallow exceptions like you are
doing. You really shouldn't ever catch Exception.

Karl

-- http://www.openmymind.net/

graphicsxp wrote:
> Hi,
> I have the following:
> Dim p As String = Server.MapPath("~/Uploads/pdf/test.pdf")
> Response.Redirect(p)
>
> The value of p is correct and the file exists. If I enter manually the
> value of p into my browser address bar, then the pdf file is properly
> opened.
>
> However from the code it doesn't work and although I've added a try
> catch block I still can't see the exception. It says:
>
>
> An exception of type 'System.Exception' occurred in myProject.DLL but
> was not handled in user code.
>
> I'm a bit lost there. Can you help ?
> Thanks
>

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      05-31-2006
> Hi,
> I have the following:
> Dim p As String = Server.MapPath("~/Uploads/pdf/test.pdf")
> Response.Redirect(p)
>
> The value of p is correct and the file exists. If I enter manually the
> value of p into my browser address bar, then the pdf file is properly
> opened.
>
> However from the code it doesn't work and although I've added a try
> catch block I still can't see the exception. It says:
>
> An exception of type 'System.Exception' occurred in myProject.DLL but
> was not handled in user code.
>
> I'm a bit lost there. Can you help ?
> Thanks


Server.MapPath translates to a *local* (to the server) filepath. The
browser (of the remote user) shouldn't be able to find the file there.
And I don't think you can redirect to a local file, that's why you get
the error.

Get the Request.ApplicationPath ("/" for a root-app, (virtual)
directory without trailing "/" for a non-root app), and append your
"Uploads/pdf/test.pdf" to that for a correct redirect path.

Hans Kesting


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
export aspx page to word format or pdf format as it is display in aspx page getmeaditi Software 0 03-10-2009 07:15 AM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
how to open word document and pdf file in aspx page Vikas Kumar ASP .Net 1 05-20-2006 05:34 AM
Syntax for call from aspx page to .cs file then to different aspx page MadHatter51 ASP .Net 1 05-17-2006 10:43 AM
Re: Open linked PDF-Files from a PDF-File Carl Prothman [MVP] ASP .Net 4 08-12-2003 09:26 AM



Advertisments