Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect to a document

Status
Not open for further replies.

tarrike

Programmer
Aug 27, 2002
6
0
0
US
Is there a way to Response.Redirect to a document (mydoc.doc)? I can create a link to the doc and it opens just fine. But when I try to redirect to it all I get is binary garbage.

Code:
  aValues(2) = "Mydoc_in_a_special_directory.ppt"
...
  page = "[URL unfurl="true"]http://www.myweb.com/admin/docs/"[/URL] & aValues(2)
  Response.Write( &quot;<br><B> DEBUG: </B> &quot; & page) 
  Response.Redirect(page)

When I comment out the .Redirect the .Write is creating the link correctly, But when it redirects I get garbage.

Any thoughts, suggestions and/or comments will be appreciated [ponder]

Thanks...
 
Hmm.. browser can't handle this way I guess.

Would you like to use javascript instead?

response.write &quot;<SCRIPT>&quot; & chr(13) & chr(10) & &quot;document.location = '&quot; & page & &quot;';&quot; & chr(13) & chr(10) &&quot;</SCRIPT>&quot;
 

I'm not at all opposed to running a script, I just need to go to the document that selected...

 
I don't have the luxury of hard coding it in. There may be from 1 to 100's of documents in the directory I am building the list from. I need to create a link to a document, be it Word, Excel or Powerpoint, log that the document was opened, and display it to the user.

Does that clear up any questions? :)

Thanks for the input...
 
The server is probably kinda executing the file and showing the text part of it (like if you open a PPT file in Notepade). There's a long function in the sitepoint forums that will probably do what you want. I can look it up if you want. -Phil
fillup07@hotmail.com
 
okay, to redirect to a document, you have to tell the server what type it is first, by using Response.ContentType.

In playing with it, this seemed to open all of my documents.
Code:
Response.ContentType = &quot;application/word&quot;

Thanks to all
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top