By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,531 Members | 873 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,531 IT Pros & Developers. It's quick & easy.

Problems opening document using response.redirect

P: 2
Hi everyone,

I'm developing an application using ASP.NET with VB, connected to a SQL Server, running on .NET 2 framework.

I am developing a training system where documents are uploaded into the system and a test is defined.

The problem I am having is when users need to view these documents. Currently, they select which item they wish to complete training on, and by clicking the start test button, it pulls the location of this document from the database and adds this file location to a variable, before using response.redirect to open the document.

Response.Redirect(LocationOfDoc)

On completion, these files will be stored on a separate network drive to the webfiles, eg Q:\ therefore are currently stored in a directory on the development machines hard drive, C:\ .

However, instead of opening the document you get an 'Object moved here' error on firefox, or a page not found on IE. One thing I have noticed is that the drive letter, eg C is changed from uppercase to lowercase during the response.redeirect which seems to be causing the problem.

For example, in the database location might be:
C:\Documents and Settings\David\application\filestore\document\docu ment1
but by the time this has been through the response.redirect it ends up invalid as:
c:\Documents and Settings\David\application\filestore\document\docu ment1

I have found many different articles about known issues with various older browsers, or adding buffer = true etc but have had no luck yet.

If anyone has any further information on this it would be greatly received.
Nov 20 '08 #1
Share this Question
Share on Google+
4 Replies


balabaster
Expert 100+
P: 797
If you cut and paste that path into the browser address bar, does it open the file successfully?
Nov 20 '08 #2

Plater
Expert 5K+
P: 7,872
I would say the issues is the file does not exist on the client's computer (drive c:\) but on the server's computer (drive c:\) response.redirect will redirect to the exact string you pass it.
So the clients browser is told to look at a file on its own computer.


Consider using the response.WriteFile() (check msdn for correct usage)
Nov 20 '08 #3

P: 2
If you cut and paste that path into the browser address bar, does it open the file successfully?
If you paste what is pulled from the database and put into the variable, the file opens fine. Its just as soon as it is used as response.redirect or as an asp hyperlink, the drive letter is changed from upper to lowercase and that is when you get the error.

Eg, response.redirect(LocationOfDocument)




I would say the issues is the file does not exist on the client's computer (drive c:\) but on the server's computer (drive c:\) response.redirect will redirect to the exact string you pass it.
So the clients browser is told to look at a file on its own computer.
All the files exist, and only one machine is currently being used for development - although are you saying that the 'client computer' and 'server computer' are acting as two machines which is why the browser can't find it? If I setup and mapped a network drive that is accessible to the client, would it be able to find it then? Or is there another way around this?

I will also look at the response.writefile option but ideally I would like the users to be able to open the file instead of printing it to the page.
Nov 20 '08 #4

Plater
Expert 5K+
P: 7,872
Well I was running under the following assumptions:
The webapplication was on computerA, and you were accessing it from a browser on computerB.
The files in question are on computerA with the webapplication, but NOT on computerB.
So when computerB tries to look for "c:\somedocument.doc", it doesn't exist because it is actually on computerA's c:\ drive.

I don't see why the difference between C:\ and c:\ would matter, but i suppose case-ing is important on some OSs
Nov 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.