473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
Nov 21 '05 #1
9 2023
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" <rg*******@spam-stubbsrich.com> a écrit dans le message de
news:O3****************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #2
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
Nov 21 '05 #3
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" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

Nov 21 '05 #4
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
Nov 21 '05 #5
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.
Nov 21 '05 #6
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
Nov 21 '05 #7
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" <rg*******@spam-stubbsrich.com> a écrit dans le message de
news:u$**************@tk2msftngp13.phx.gbl...
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.

Nov 21 '05 #8
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" <no****@nowhere.com> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
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" <rg*******@spam-stubbsrich.com> a écrit dans le message de
news:u$**************@tk2msftngp13.phx.gbl...
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.


Nov 21 '05 #9
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" <ma****@SPAMrussgreen.com> a écrit dans le message de
news:ee**************@TK2MSFTNGP12.phx.gbl...
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" <no****@nowhere.com> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
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" <rg*******@spam-stubbsrich.com> a écrit dans le message de
news:u$**************@tk2msftngp13.phx.gbl...
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.



Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nico | last post by:
I try to execute a shell command from ASP with: response.write("start") Set wshShell = CreateObject("WScript.Shell") wshShell.Run "notepad" Set wshShell = Nothing response.write("finished") ...
7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
21
by: ryanmhuc | last post by:
I know the subject might be confusing. I am no beginner with javascript but I haven't been able to figure out how to get the javascript file name from code inside the file. So you have an HTML...
1
by: GDURAN | last post by:
How can create a file at client-side? I need verify (find, create and delete) a temp file at client side. How search a path(file) in differents OS (mac, windows)
4
by: Michael | last post by:
I am trying to open a file on the client machine from an aspx page running server side. The design requirements of the page specify that the HtmlInputFile control is not to be used. Since the...
6
by: Steve Richter | last post by:
I am getting error in a vbscript: ActiveX component cant create object: Excel.Application. The vbscript code is: Dim objExcel Set objExcel = CreateObject("Excel.Application") I am pretty...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
11
by: Russ Green | last post by:
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...
7
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function Body_Onload() ' create the object Set obj = Server.CreateObject("UploadImage.cTest") ' use method of the object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.