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
I need help writing a method to create a simple text file. I want that file
to be saved to a local drive (client side of my asp.net app). The filename
will always be the same "license.txt" but the content will be different for
each user. I don't really want to create the file on my server and them have
them downloaded it. I would much rather use a stringbuilder and the save the
contents of the stringbuilder to the users local drive (propted of course).

TIA

Russ


 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      05-19-2005
Russ Green wrote:
> I need help writing a method to create a simple text file. I want that file
> to be saved to a local drive (client side of my asp.net app). The filename
> will always be the same "license.txt" but the content will be different for
> each user. I don't really want to create the file on my server and them have
> them downloaded it. I would much rather use a stringbuilder and the save the
> contents of the stringbuilder to the users local drive (propted of course).
>
> TIA
>
> Russ
>
>


The classic download/upload example:

http://www.ondotnet.com/pub/a/dotnet...04/01/asp.html

Instead of WriteFile, just Write the builder.ToString()

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      05-19-2005
If this is to raise the "save file" prompt, try :
http://support.microsoft.com/kb/260519/en-us

Else tell use what is the exact point on which you need help...

Of course once the file is saved you won't be able to access it (don't
really know if it will be usefull then...)

Patrice

--

"Russ Green" <rgreen-> a écrit dans le message de
news:O3YOj%...
> I need help writing a method to create a simple text file. I want that

file
> to be saved to a local drive (client side of my asp.net app). The filename
> will always be the same "license.txt" but the content will be different

for
> each user. I don't really want to create the file on my server and them

have
> them downloaded it. I would much rather use a stringbuilder and the save

the
> contents of the stringbuilder to the users local drive (propted of

course).
>
> TIA
>
> Russ
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      05-19-2005
Russ,

You can not write even a simple file on the userside with ASPNET with normal
security settings.

However you can add information to the cookies which are normally (in non
cookieless mode) set on the clients computer. You can reread that as well.
(don't forget to set the expire date.

I hope this helps,

Cor


 
Reply With Quote
 
Russ Green
Guest
Posts: n/a
 
      05-19-2005
I'm not trying to write the file directly to the users hard disk. What I
want to do is allow them the dow2nload the file when they click a link. What
I don't want, is to generate that file physically on my server. II would
like, if possible, to generate that file in memory and then present the user
with the standard download dialog so they can choose to download the file on
their system.


"Cor Ligthert" <> wrote in message
news:%...
> Russ,
>
> You can not write even a simple file on the userside with ASPNET with
> normal security settings.
>
> However you can add information to the cookies which are normally (in non
> cookieless mode) set on the clients computer. You can reread that as well.
> (don't forget to set the expire date.
>
> I hope this helps,
>
> Cor
>



 
Reply With Quote
 
Russ Green
Guest
Posts: n/a
 
      05-19-2005
Thanks,

I currently have this little test I'm working on. It doesn't make a file and
present the user with the download dialog it just displays the sb string in
the web browser.

Help!!!

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("line 1" & vbcrLf)
sb.Append("line 2" & vbcrLf)

'Set the appropriate ContentType.
Response.ContentType = "text/plain"

' Add a header telling the browser
' to expect an attachment and give it the
' name of the attachment
Dim filename As String = "license.lic"
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


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      05-19-2005
Russ,

Sorry, however why do you do it in an other way as everybody else.
Everybody shows that page and than the user can decide himself to save it or
not. What is the advantage from the method you want to do.

It seems to me especially in the EU a less juridistic good way

Just my thought,

Cor


 
Reply With Quote
 
Russ Green
Guest
Posts: n/a
 
      05-19-2005
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
 
Cor Ligthert
Guest
Posts: n/a
 
      05-19-2005
Russ,

Why not create an unique page for them.
They have a save as button on their browser (there is as well javascript to
do that).

Cor


 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      05-19-2005
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" <rgreen-> a écrit dans le message de
news:u$...
> 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
 
 
 
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
 



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