473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

can't open pdf file from aspx page

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

May 31 '06 #1
2 3297
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

May 31 '06 #2
> 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
May 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sarah Bram | last post by:
Hi, I have created an ASP.NET app / page with Microsoft Visual Studio .NET 2003 using C# But, when I closed VS and re-opened it later, I see all files in my project, except the webform I had...
1
by: Poppy | last post by:
I opened an asp page in VS.net 2002 and then saved it as an aspx page, "mypage.aspx". I was prompted if I wanted to create the class file for the page and clicked yes. Now when I try and open...
7
by: Mark Goldin | last post by:
If I want to open a new ASPX page when the user clicks on a button do I use JS for that? What would be a point of having AutoPostBack enabled for that button if I cannot use server side to open a...
3
by: serge calderara | last post by:
Dear all, I have a simple web application with a starting page as WebForm.aspx If I run my application locally from my workstation (W200 SP4) it works fine. Then I copy my all application under...
2
by: David Lozzi | last post by:
Howdy, Trying to open and read/write another aspx file from my aspx page. Basically I want to be able to update my aspx files from the website. Here's my code so far: Dim path As String =...
0
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
6
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any)....
2
by: Seok Bee | last post by:
Dear Experts, In my web application, I am having a button to open a file located in the server. When I click on the button to view the file, I received the following error message:...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
2
by: AAaron123 | last post by:
Useing vs2008 I created a new web site. I opened .aspx file to get the tab titled Default.aspx, which has the views: Source, Split and Design I draged a couple of components on to the .aspx...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.