AGAIN.AGAIN: Downloading files from my aspx page

AGAIN.AGAIN: Downloading files from my aspx page

Post by Troy Simpso » Wed, 30 Jan 2002 15:47:27



Hi,

I know this subject has been nearly beaten to death, but at this stage, none
of the posts in this group actually work - that's why I need relevent
answers to this only please... don't repeat a previous post that doesn't
work; it doesn't really help, and you probably won't get your mvp ;) (BTW,
this is not belittling anyone, it's just a fact of life that security
patches and software updates have been released which prevent the more
classic code from working).

The people who posted in Luhar's thread (25.Jan.2002) almost had the answer,
but basically, the code does not produce any working results.  I believe
this may be to do with Microsoft's security patch related to a * problem
with content disposition.

I can get a client browser to popup a download box on **filetypes mapped on
the client system**, but my visitors will be coming from all over the place,
so I can't be supporting everyone who cannot map the files at their end.

What I want to achieve is this :

* have a file download pool EXternal to the website
* have a little aspx file which is capable of picking up a local file from
my EXternal download pool and telling a client browser to download it

What I have already proven NOT to work :

* content disposition (killed by the MS security patch)
* all forms of file streaming (I think this is related to content
disposition - you cannot workaround the block on malicious behaviour)

Please do not repost any examples on this subject from this group because
none of them work reliably.

If I cannot get this to work reliably on all client machines, then can
someone please give me an idea on how they provide file download
capabilities with CGI/perl etc (I'm guessing it's streaming or something),
or anything at all that *works*.

Cheers People
Troy Simpson

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Tim Overba » Thu, 31 Jan 2002 00:17:25


Here here! I was getting a little discouraged about that and put it aside.
I'm glad I'm not the only one who wants an answer to this problem.

Thanks Troy,

Tim Overbay (Luhar)


Quote:> Hi,

> I know this subject has been nearly beaten to death, but at this stage,
none
> of the posts in this group actually work - that's why I need relevent
> answers to this only please... don't repeat a previous post that doesn't
> work; it doesn't really help, and you probably won't get your mvp ;) (BTW,
> this is not belittling anyone, it's just a fact of life that security
> patches and software updates have been released which prevent the more
> classic code from working).

> The people who posted in Luhar's thread (25.Jan.2002) almost had the
answer,
> but basically, the code does not produce any working results.  I believe
> this may be to do with Microsoft's security patch related to a *
problem
> with content disposition.

> I can get a client browser to popup a download box on **filetypes mapped
on
> the client system**, but my visitors will be coming from all over the
place,
> so I can't be supporting everyone who cannot map the files at their end.

> What I want to achieve is this :

> * have a file download pool EXternal to the website
> * have a little aspx file which is capable of picking up a local file from
> my EXternal download pool and telling a client browser to download it

> What I have already proven NOT to work :

> * content disposition (killed by the MS security patch)
> * all forms of file streaming (I think this is related to content
> disposition - you cannot workaround the block on malicious behaviour)

> Please do not repost any examples on this subject from this group because
> none of them work reliably.

> If I cannot get this to work reliably on all client machines, then can
> someone please give me an idea on how they provide file download
> capabilities with CGI/perl etc (I'm guessing it's streaming or something),
> or anything at all that *works*.

> Cheers People
> Troy Simpson


 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Michael Giagnocav » Thu, 31 Jan 2002 01:58:37


What does this mean:

Quote:> > What I want to achieve is this :

> > * have a file download pool EXternal to the website
> > * have a little aspx file which is capable of picking up a local file from
> > my EXternal download pool and telling a client browser to download it

What do you mean by Download Pool EXternal and "picking up a local file"?

Thanks,
-Mike


> Here here! I was getting a little discouraged about that and put it aside.
> I'm glad I'm not the only one who wants an answer to this problem.

> Thanks Troy,

> Tim Overbay (Luhar)



> > Hi,

> > I know this subject has been nearly beaten to death, but at this stage,
> none
> > of the posts in this group actually work - that's why I need relevent
> > answers to this only please... don't repeat a previous post that doesn't
> > work; it doesn't really help, and you probably won't get your mvp ;) (BTW,
> > this is not belittling anyone, it's just a fact of life that security
> > patches and software updates have been released which prevent the more
> > classic code from working).

> > The people who posted in Luhar's thread (25.Jan.2002) almost had the
> answer,
> > but basically, the code does not produce any working results.  I believe
> > this may be to do with Microsoft's security patch related to a *
> problem
> > with content disposition.

> > I can get a client browser to popup a download box on **filetypes mapped
> on
> > the client system**, but my visitors will be coming from all over the
> place,
> > so I can't be supporting everyone who cannot map the files at their end.

> > What I want to achieve is this :

> > * have a file download pool EXternal to the website
> > * have a little aspx file which is capable of picking up a local file from
> > my EXternal download pool and telling a client browser to download it

> > What I have already proven NOT to work :

> > * content disposition (killed by the MS security patch)
> > * all forms of file streaming (I think this is related to content
> > disposition - you cannot workaround the block on malicious behaviour)

> > Please do not repost any examples on this subject from this group because
> > none of them work reliably.

> > If I cannot get this to work reliably on all client machines, then can
> > someone please give me an idea on how they provide file download
> > capabilities with CGI/perl etc (I'm guessing it's streaming or something),
> > or anything at all that *works*.

> > Cheers People
> > Troy Simpson

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Troy Simpso » Thu, 31 Jan 2002 07:44:31


Michael,

This means that my file is external to the website itself (I just emphasised
the EX).  If the website is in e:\inetpub\wwwroot\ I want files stored in
e:\DownloadPool (which is not connected as a virtual directory).  From the
aspx code, I want users to be able to download the file
"e:\DownloadPool\myfile.xyz" without using any direct links... in other
words, the code points to that file and sends it down to the user.


> What does this mean:

> > > What I want to achieve is this :

> > > * have a file download pool EXternal to the website
> > > * have a little aspx file which is capable of picking up a local file
from
> > > my EXternal download pool and telling a client browser to download it

> What do you mean by Download Pool EXternal and "picking up a local file"?

> Thanks,
> -Mike




- Show quoted text -

> > Here here! I was getting a little discouraged about that and put it
aside.
> > I'm glad I'm not the only one who wants an answer to this problem.

> > Thanks Troy,

> > Tim Overbay (Luhar)



> > > Hi,

> > > I know this subject has been nearly beaten to death, but at this
stage,
> > none
> > > of the posts in this group actually work - that's why I need relevent
> > > answers to this only please... don't repeat a previous post that
doesn't
> > > work; it doesn't really help, and you probably won't get your mvp ;)
(BTW,
> > > this is not belittling anyone, it's just a fact of life that security
> > > patches and software updates have been released which prevent the more
> > > classic code from working).

> > > The people who posted in Luhar's thread (25.Jan.2002) almost had the
> > answer,
> > > but basically, the code does not produce any working results.  I
believe
> > > this may be to do with Microsoft's security patch related to a *
> > problem
> > > with content disposition.

> > > I can get a client browser to popup a download box on **filetypes
mapped
> > on
> > > the client system**, but my visitors will be coming from all over the
> > place,
> > > so I can't be supporting everyone who cannot map the files at their
end.

> > > What I want to achieve is this :

> > > * have a file download pool EXternal to the website
> > > * have a little aspx file which is capable of picking up a local file
from
> > > my EXternal download pool and telling a client browser to download it

> > > What I have already proven NOT to work :

> > > * content disposition (killed by the MS security patch)
> > > * all forms of file streaming (I think this is related to content
> > > disposition - you cannot workaround the block on malicious behaviour)

> > > Please do not repost any examples on this subject from this group
because
> > > none of them work reliably.

> > > If I cannot get this to work reliably on all client machines, then can
> > > someone please give me an idea on how they provide file download
> > > capabilities with CGI/perl etc (I'm guessing it's streaming or
something),
> > > or anything at all that *works*.

> > > Cheers People
> > > Troy Simpson

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Tim Overba » Thu, 31 Jan 2002 09:18:01


Whew! I finally got enough clues to figure this out. I started a blank
solution and added a new VB Class file. I wrote a class that implemented the
System.Web.IHttpHandler interface:


Imports System.Web

Public Class GetMap
  Implements IHttpHandler

  Public Sub ProcessRequest(Context As HttpContext) Implements
IHttpHandler.ProcessRequest
    Dim MKMapPath As String = Context.Request("Name") + ".Map"

    Context.Response.ContentType = "multipart/form-data"
    Context.Response.WriteFile(MKMapPath)
  End Sub

  Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
      Get
          Return True
      End Get
  End Property
End Class

Saved the file, renamed it with an .ashx extension and copied it to my web
server. Now I can do "http://www.myweb.com/GetMap?Name=MyMap" and it
initiates the file download process.

Pretty simple, but MAN it was tough getting the right information.

Thanks for the help,

Tim Overbay


Quote:> You mean like:

> Response.ContentType="image/jpeg"
> Response.WriteFile("C:\images\001.jpg")
> ?

> -mike

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Tim Overba » Thu, 31 Jan 2002 09:25:02


Oops! Got a little too e*d there... It downloads the file all right, but
names it GetMap.ashx instead of the name of the Map file. Ugh! Now what?

Tim Overbay
BTW, If you haven't noticed yet, I'm a complete newbie to web programming in
general and ASP.NET programming in particular. I grew up writing stand-alone
Windows apps.

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Jim Ross [MVP » Thu, 31 Jan 2002 10:54:03


Try adding:
Context.Response.Addheader("Content-Disposition", MKMapPath)


>Whew! I finally got enough clues to figure this out. I started a blank
>solution and added a new VB Class file. I wrote a class that implemented the
>System.Web.IHttpHandler interface:


>Imports System.Web

>Public Class GetMap
>  Implements IHttpHandler

>  Public Sub ProcessRequest(Context As HttpContext) Implements
>IHttpHandler.ProcessRequest
>    Dim MKMapPath As String = Context.Request("Name") + ".Map"

>    Context.Response.ContentType = "multipart/form-data"
>    Context.Response.WriteFile(MKMapPath)
>  End Sub

>  Public ReadOnly Property IsReusable() As Boolean Implements
>IHttpHandler.IsReusable
>      Get
>          Return True
>      End Get
>  End Property
>End Class

>Saved the file, renamed it with an .ashx extension and copied it to my web
>server. Now I can do "http://www.myweb.com/GetMap?Name=MyMap" and it
>initiates the file download process.

>Pretty simple, but MAN it was tough getting the right information.

>Thanks for the help,

>Tim Overbay



>> You mean like:

>> Response.ContentType="image/jpeg"
>> Response.WriteFile("C:\images\001.jpg")
>> ?

>> -mike

Jim Ross
MS MVP [VC/MFC]

Remove "nospam" to send email, but please ask all questions in the newsgroups, not via private mail

 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Troy Simpso » Thu, 31 Jan 2002 15:23:45


Well....

You guys have successfully gotten my post and turned it the full circle back
to where all the other posts started... has *anyone* applied microsoft's
security patches, or is it just my two development computers which cannot
perform this trick...?  All I get, no matter what, is the file with the
extension .ashx, and I believe this is directly related to Microsoft's patch
of the content disposition exploit... and the code given here is exactly
that... content-disposition!!  Would it not matter if this content
disposition was tangled up in a class, or included as plain aspx code??  All
this stuff is just variations of the same problems, and I already ruled this
option out in my first post!!

Next-time, before we get back to all the old code posted in the group, can
the poster test code using a machine with current security patches, and we
might be able to put this issue to rest!!!  If it's me that's wrong, I'll be
happy, as long as somebody can point out what the hell is happening here.
I've already scoured the web, so I don't need anyone telling me to leave it
up to my imagination either.  Thanks, sorry for the moaning.

Below is the corrected code, saved as getmap.ashx.  You call it with
http://localhost/getmap.ashx?name=mymap.  Make sure you have a file called
mymap.map in the root folder of the web.  This code asks you where to save a
file called mymap.ashx... useless!!


Imports System.Web

Public Class GetMap : Implements IHttpHandler

 Public Sub ProcessRequest(Context As HttpContext) Implements
IHttpHandler.ProcessRequest
  Dim MKMapPath As String = Context.Request("Name") + ".Map"

  Context.Response.Addheader("Content-Disposition", MKMapPath)
  Context.Response.ContentType = "multipart/form-data"
  Context.Response.WriteFile(MKMapPath)
 End Sub

 Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
  Get
   Return True
  End Get
 End Property
End Class



> Try adding:
> Context.Response.Addheader("Content-Disposition", MKMapPath)


> >Whew! I finally got enough clues to figure this out. I started a blank
> >solution and added a new VB Class file. I wrote a class that implemented
the
> >System.Web.IHttpHandler interface:


> >Imports System.Web

> >Public Class GetMap
> >  Implements IHttpHandler

> >  Public Sub ProcessRequest(Context As HttpContext) Implements
> >IHttpHandler.ProcessRequest
> >    Dim MKMapPath As String = Context.Request("Name") + ".Map"

> >    Context.Response.ContentType = "multipart/form-data"
> >    Context.Response.WriteFile(MKMapPath)
> >  End Sub

> >  Public ReadOnly Property IsReusable() As Boolean Implements
> >IHttpHandler.IsReusable
> >      Get
> >          Return True
> >      End Get
> >  End Property
> >End Class

> >Saved the file, renamed it with an .ashx extension and copied it to my
web
> >server. Now I can do "http://www.myweb.com/GetMap?Name=MyMap" and it
> >initiates the file download process.

> >Pretty simple, but MAN it was tough getting the right information.

> >Thanks for the help,

> >Tim Overbay



> >> You mean like:

> >> Response.ContentType="image/jpeg"
> >> Response.WriteFile("C:\images\001.jpg")
> >> ?

> >> -mike

> Jim Ross
> MS MVP [VC/MFC]

> Remove "nospam" to send email, but please ask all questions in the

newsgroups, not via private mail
 
 
 

AGAIN.AGAIN: Downloading files from my aspx page

Post by Tim Overba » Thu, 31 Jan 2002 16:33:49


Hmmm... This is rather frustrating, but at least you seem to know what
you're doing.

Here's another shot in the dark: Is there anything that needs to be added to
the httphandlers section of the web.config file?

Something like:

<httphandlers>
  <add verb="*.Map" path="GetMap.ashx" type="SlipStream.GetMap,GetMap" />
</httphandlers>

Tim Overbay


> Well....

> You guys have successfully gotten my post and turned it the full circle
back
> to where all the other posts started... has *anyone* applied microsoft's
> security patches, or is it just my two development computers which cannot
> perform this trick...?  All I get, no matter what, is the file with the
> extension .ashx, and I believe this is directly related to Microsoft's
patch
> of the content disposition exploit... and the code given here is exactly
> that... content-disposition!!  Would it not matter if this content
> disposition was tangled up in a class, or included as plain aspx code??
All
> this stuff is just variations of the same problems, and I already ruled
this
> option out in my first post!!

> Next-time, before we get back to all the old code posted in the group, can
> the poster test code using a machine with current security patches, and we
> might be able to put this issue to rest!!!  If it's me that's wrong, I'll
be
> happy, as long as somebody can point out what the hell is happening here.
> I've already scoured the web, so I don't need anyone telling me to leave
it
> up to my imagination either.  Thanks, sorry for the moaning.

> Below is the corrected code, saved as getmap.ashx.  You call it with
> http://localhost/getmap.ashx?name=mymap.  Make sure you have a file called
> mymap.map in the root folder of the web.  This code asks you where to save
a
> file called mymap.ashx... useless!!


> Imports System.Web

> Public Class GetMap : Implements IHttpHandler

>  Public Sub ProcessRequest(Context As HttpContext) Implements
> IHttpHandler.ProcessRequest
>   Dim MKMapPath As String = Context.Request("Name") + ".Map"

>   Context.Response.Addheader("Content-Disposition", MKMapPath)
>   Context.Response.ContentType = "multipart/form-data"
>   Context.Response.WriteFile(MKMapPath)
>  End Sub

>  Public ReadOnly Property IsReusable() As Boolean Implements
> IHttpHandler.IsReusable
>   Get
>    Return True
>   End Get
>  End Property
> End Class



> > Try adding:
> > Context.Response.Addheader("Content-Disposition", MKMapPath)


> > >Whew! I finally got enough clues to figure this out. I started a blank
> > >solution and added a new VB Class file. I wrote a class that
implemented
> the
> > >System.Web.IHttpHandler interface:


> > >Imports System.Web

> > >Public Class GetMap
> > >  Implements IHttpHandler

> > >  Public Sub ProcessRequest(Context As HttpContext) Implements
> > >IHttpHandler.ProcessRequest
> > >    Dim MKMapPath As String = Context.Request("Name") + ".Map"

> > >    Context.Response.ContentType = "multipart/form-data"
> > >    Context.Response.WriteFile(MKMapPath)
> > >  End Sub

> > >  Public ReadOnly Property IsReusable() As Boolean Implements
> > >IHttpHandler.IsReusable
> > >      Get
> > >          Return True
> > >      End Get
> > >  End Property
> > >End Class

> > >Saved the file, renamed it with an .ashx extension and copied it to my
> web
> > >server. Now I can do "http://www.myweb.com/GetMap?Name=MyMap" and it
> > >initiates the file download process.

> > >Pretty simple, but MAN it was tough getting the right information.

> > >Thanks for the help,

> > >Tim Overbay



> > >> You mean like:

> > >> Response.ContentType="image/jpeg"
> > >> Response.WriteFile("C:\images\001.jpg")
> > >> ?

> > >> -mike

> > Jim Ross
> > MS MVP [VC/MFC]

> > Remove "nospam" to send email, but please ask all questions in the
> newsgroups, not via private mail

 
 
 

1. AGAIN: Downloading certain file types from my aspx page...

Sorry for the repost, but I really need some help getting this resolved.

I have an ASPX page that uses a data repeater to show information about
files that users have uploaded. One of the entries is a link to download the
file:

<A href='<%# DataBinder.Eval(Container.DataItem, "Title") + ".Map"
%>'>Download</a>

The files that this website is dealing with are .Map files which are
user-drawn maps for an online strategy game. The hyperlinks show up just
fine when the page is loaded, but when I click on a link to download the
file, it just reloads the page. I don't get a SaveAs dialog box. The only
way I can download the file is to right-click on the link and select 'Save
As...'

I suspect it's a problem with the extension. Is there some sort of file
format that uses '.Map' as an extension that my web server might be handling
differently? Can I write my own httphandler to handle '.Map' files? If so,
how? I wouldn't mind sending the map file name to an ASHX page to handle the
downloading, but I can't find enough information on ASHX files.

Any help with this would be greatly appreciated.

Tim Overbay

2. Routing mail

3. OnGetDispInfo is called again and again....

4. How to fix the problem "file header is full"?

5. Addin brings up installer again and again

6. Do synchronous I/O need APC?

7. OnGetDispInfo is called again & again.....

8. Undoc. dos calls illegal?

9. Setup failed... again and again!

10. VS.NET and VSS - again, again

11. MSDN subscription downloads out of service again!!!

12. Response.BinaryWrite downloading aspx page instead of streamed file