Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Create file client side with VB.NET and ASP.NET

Reply
Thread Tools

Create file client side with VB.NET and ASP.NET

 
 
Russ Green
Guest
Posts: n/a
 
      05-19-2005
This code has just done exactly what I want it to on my PC at home.
Brilliant!! When I tried it in work earlier it wasn't working. Why? What
could stop it working on some browsers?

Private Sub Page_Load (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' Create a stringbuilder to hold the text to be sent

Dim sb As New System.Text.StringBuilder

' Add the text content to the stringbuilder

sb.Append("<?xml version=1.0 encoding=UTF-8 ?>" & vbcrLf)

sb.Append("<configuration>" & vbcrLf)

sb.Append("</configuration>" & vbcrLf)

' Set the appropriate ContentType.

Response.ContentType = "text/xml"

' Add a header telling the browser

' to expect an attachment and give it the

' name of the attachment

Dim filename As String = "license.xml"

Response.AddHeader("Content-Disposition", _

"attachment; filename=""" & filename & """")

' Write the file's content from the stringbuilder

' directly to the HTTP output stream.

Response.Write(sb.ToString)

Response.End()

End Sub

"Patrice" <(E-Mail Removed)> wrote in message
news:O%(E-Mail Removed)...
> In case you missed my message :
> http://support.microsoft.com/kb/260519/en-us shows how to raise the "save
> as" box.
>
> Addtionaly use just Response.Write to write down the file content (client
> side the browser doesn't know where the content comes, it just see
> incoming
> bytes). The article is for ASP but applies as well to ASP.NET...
>
> Patrice
>
> --
>
> "Russ Green" <(E-Mail Removed)> a écrit dans le message de
> news:u$(E-Mail Removed)...
>> Well what I'm actually trying to do is generate a license file for a user

> to
>> download. The content will be unique to any particular user. I want that
>> user to login to my site. Click a link and be presented with a dialog for
>> them to download their very own unique license file. I've seen it done
>> before.
>>
>>

>
>



 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      05-19-2005
This article list that ie 4.01 is know to have problems with this.

How does it fail ? (it displays the XML ?)

IMO a browser could perhaps just check the content type and handle this
regardless of the content-disposition header... I would try without with the
content-type or with a fictionous content type. I would try also a different
extension for the filename (just random tries to try to undestand what is
the element that causes the problem).

Patrice

--

"Russ Green" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> This code has just done exactly what I want it to on my PC at home.
> Brilliant!! When I tried it in work earlier it wasn't working. Why? What
> could stop it working on some browsers?
>
> Private Sub Page_Load (ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ' Create a stringbuilder to hold the text to be sent
>
> Dim sb As New System.Text.StringBuilder
>
> ' Add the text content to the stringbuilder
>
> sb.Append("<?xml version=1.0 encoding=UTF-8 ?>" & vbcrLf)
>
> sb.Append("<configuration>" & vbcrLf)
>
> sb.Append("</configuration>" & vbcrLf)
>
> ' Set the appropriate ContentType.
>
> Response.ContentType = "text/xml"
>
> ' Add a header telling the browser
>
> ' to expect an attachment and give it the
>
> ' name of the attachment
>
> Dim filename As String = "license.xml"
>
> Response.AddHeader("Content-Disposition", _
>
> "attachment; filename=""" & filename & """")
>
> ' Write the file's content from the stringbuilder
>
> ' directly to the HTTP output stream.
>
> Response.Write(sb.ToString)
>
> Response.End()
>
> End Sub
>
> "Patrice" <(E-Mail Removed)> wrote in message
> news:O%(E-Mail Removed)...
> > In case you missed my message :
> > http://support.microsoft.com/kb/260519/en-us shows how to raise the

"save
> > as" box.
> >
> > Addtionaly use just Response.Write to write down the file content

(client
> > side the browser doesn't know where the content comes, it just see
> > incoming
> > bytes). The article is for ASP but applies as well to ASP.NET...
> >
> > Patrice
> >
> > --
> >
> > "Russ Green" <(E-Mail Removed)> a écrit dans le message de
> > news:u$(E-Mail Removed)...
> >> Well what I'm actually trying to do is generate a license file for a

user
> > to
> >> download. The content will be unique to any particular user. I want

that
> >> user to login to my site. Click a link and be presented with a dialog

for
> >> them to download their very own unique license file. I've seen it done
> >> before.
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
 
 
 
thegreatone thegreatone is offline
Junior Member
Join Date: Feb 2012
Posts: 1
 
      02-07-2012
hello guys,
i am quite new to all this ASP.NET so bear with me,
how can i create the following process:

From my ASP page, when a user clicks a button, a file is generated on the server-side and then transmitted to the users hard disk and stored in a specified directory that i will have specified in code.

Thank you in advance, really appreciate your helo
 
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
How to execute client-side code _after_ client-side validation? Bogdan ASP .Net 2 06-09-2008 01:31 PM
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
get image side via client side script before file uplaod moondaddy ASP .Net 2 07-16-2004 04:50 AM
suggestions on: Create/delete/modify element(s) for server side from Javascript/client-side? Shaul Feldman ASP .Net 0 04-16-2004 09:55 PM
Adding custom client-side onClick handler with client-side validator controls Zoe Hart ASP .Net Web Controls 1 01-08-2004 10:45 PM



Advertisments