Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Content-Disposition attatchment question

Reply
Thread Tools

Content-Disposition attatchment question

 
 
Martin
Guest
Posts: n/a
 
      07-31-2007
I have a link in a page that allows the user to download a dynamically
created XLS file. I add these headers and everything works correctly -
as long as the .xls file is in the "home" folder.
AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
AddHeader("Content-type", "application/xls")

But, I would like to create the file in a sub-folder and send it out
from there. I've tried putting in a pathname like so:
filename=\subfolder\MyFile.xls but I can't get anything to work (the
response to the user is "File not found".

How can I get this to work?
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-31-2007
The name should be relative to your server application root.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Martin" <> wrote in message
news:...
>I have a link in a page that allows the user to download a dynamically
> created XLS file. I add these headers and everything works correctly -
> as long as the .xls file is in the "home" folder.
> AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
> AddHeader("Content-type", "application/xls")
>
> But, I would like to create the file in a sub-folder and send it out
> from there. I've tried putting in a pathname like so:
> filename=\subfolder\MyFile.xls but I can't get anything to work (the
> response to the user is "File not found".
>
> How can I get this to work?



 
Reply With Quote
 
 
 
 
Martin
Guest
Posts: n/a
 
      07-31-2007
On Tue, 31 Jul 2007 17:52:05 +0300, "Eliyahu Goldin"
<> wrote:

>The name should be relative to your server application root.


That's what I'm doing. I created a sub-folder named XLSFiles in the
server root. That's where I'm creating the xls files.

Can you give me an example of the exact syntax to use?

Is it filename=\XLSFiles\MyFile.xls
Or filename=.\XLSFiles\MyFile.xls
Or filename=..\XLSFiles\MyFile.xls
Or filename=\XLSFiles/MyFile.xls
Or ...

I've tried everything I can think of - nothing works.


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-31-2007
It should be server application root, off the application virtual directory.

And the path will be

XLSFiles/MyFile.xls

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Martin" <> wrote in message
news:...
> On Tue, 31 Jul 2007 17:52:05 +0300, "Eliyahu Goldin"
> <> wrote:
>
>>The name should be relative to your server application root.

>
> That's what I'm doing. I created a sub-folder named XLSFiles in the
> server root. That's where I'm creating the xls files.
>
> Can you give me an example of the exact syntax to use?
>
> Is it filename=\XLSFiles\MyFile.xls
> Or filename=.\XLSFiles\MyFile.xls
> Or filename=..\XLSFiles\MyFile.xls
> Or filename=\XLSFiles/MyFile.xls
> Or ...
>
> I've tried everything I can think of - nothing works.
>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      07-31-2007
IMO it could be unrelated. Content-disposition just suggests a name for the
downloaded file (it doesn't even have to be an existing file).

For now it's a bit unclear but it would make me rather think that the
problem is in the code that streams the file to the browser. This is where
the updated location should be taken into account.

---
Patrice

"Martin" <> a écrit dans le message de news:
...
>I have a link in a page that allows the user to download a dynamically
> created XLS file. I add these headers and everything works correctly -
> as long as the .xls file is in the "home" folder.
> AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
> AddHeader("Content-type", "application/xls")
>
> But, I would like to create the file in a sub-folder and send it out
> from there. I've tried putting in a pathname like so:
> filename=\subfolder\MyFile.xls but I can't get anything to work (the
> response to the user is "File not found".
>
> How can I get this to work?



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      08-02-2007
I agree with what you're saying. Do you have any idea as to how I
would get the server to use a different location? It seems to be able
to find the created file only if I put it in the server's application
root directory.

I tried creating a virtual directory named XLSFiles but that made no
difference.



On Tue, 31 Jul 2007 17:41:52 +0200, "Patrice"
<http://www.chez.com/scribe/> wrote:

>IMO it could be unrelated. Content-disposition just suggests a name for the
>downloaded file (it doesn't even have to be an existing file).
>
>For now it's a bit unclear but it would make me rather think that the
>problem is in the code that streams the file to the browser. This is where
>the updated location should be taken into account.
>
>---
>Patrice
>
>"Martin" <> a écrit dans le message de news:
>...
>>I have a link in a page that allows the user to download a dynamically
>> created XLS file. I add these headers and everything works correctly -
>> as long as the .xls file is in the "home" folder.
>> AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
>> AddHeader("Content-type", "application/xls")
>>
>> But, I would like to create the file in a sub-folder and send it out
>> from there. I've tried putting in a pathname like so:
>> filename=\subfolder\MyFile.xls but I can't get anything to work (the
>> response to the user is "File not found".
>>
>> How can I get this to work?

>


 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      08-03-2007
If this is a virtual directory you'll have to user Server.MapPath to
transform this location into a physical server side directory. Using the
full absolute path of the file you can then use Response.WriteFile to stream
the file from this location .

For now you could just stream a sample text file directly to the browser
wihtout the content disposition header so that you can see whatever happens
includiong a possible error. Also try first to write down just the file
location so that you can check the absolute path is correct...

For now I would say that the file location is not correctly created
resulting in not finding the file...

--
Patrice

"Martin" <> a écrit dans le message de news:
...
>I agree with what you're saying. Do you have any idea as to how I
> would get the server to use a different location? It seems to be able
> to find the created file only if I put it in the server's application
> root directory.
>
> I tried creating a virtual directory named XLSFiles but that made no
> difference.
>
>
>
> On Tue, 31 Jul 2007 17:41:52 +0200, "Patrice"
> <http://www.chez.com/scribe/> wrote:
>
>>IMO it could be unrelated. Content-disposition just suggests a name for
>>the
>>downloaded file (it doesn't even have to be an existing file).
>>
>>For now it's a bit unclear but it would make me rather think that the
>>problem is in the code that streams the file to the browser. This is where
>>the updated location should be taken into account.
>>
>>---
>>Patrice
>>
>>"Martin" <> a écrit dans le message de news:
>>...
>>>I have a link in a page that allows the user to download a dynamically
>>> created XLS file. I add these headers and everything works correctly -
>>> as long as the .xls file is in the "home" folder.
>>> AddHeader("Content-Disposition", "attachment; filename=MyFile.xls")
>>> AddHeader("Content-type", "application/xls")
>>>
>>> But, I would like to create the file in a sub-folder and send it out
>>> from there. I've tried putting in a pathname like so:
>>> filename=\subfolder\MyFile.xls but I can't get anything to work (the
>>> response to the user is "File not found".
>>>
>>> How can I get this to work?

>>

>



 
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
Dynamically add XML as an attatchment from Stream UnglueD ASP .Net 0 10-04-2006 06:11 PM
Use DIME/attatchment to download an application =?Utf-8?B?TmlrbGFz?= ASP .Net 0 08-10-2004 06:35 AM
Outlook Express attatchment problems ak Computer Support 3 05-25-2004 07:17 AM
Attatchment Pete & Jean Computer Support 2 11-02-2003 04:11 PM
OE removed an unsafe attatchment in my e-mail Andrew Mott Computer Support 13 09-02-2003 10:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57