468,765 Members | 1,384 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Save a file on client

Is there a way to write a file on the client machine from an aspx page? I've
a custom query page and need to store the search criteria specified in an
XML file on the user machine from my web page (aspx). I form the XML at run
time from the search fileds specfied by the user and now my aspx page should
save it on client machine so that the user can open the same query on next
visit of the page.

And help is appreciated.

Nikhil
Nov 18 '05 #1
4 3770
Hi, Nikhil Tayal,

If the info is not that large you can save it as a cookie on the client.

If it is really large you can prompt the user to save it and on the next
visit to upload it. This is very bad design regarding the security though,
because the users can upload practically anything.

A standard solution is to keep this data in the server in the profile of the
user (supposing that you keep the profiles of your users and they (may)
authenticate before the visit to the page).

Greetings
Martin
"Nikhil Tayal" <a-******@microsoft.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Is there a way to write a file on the client machine from an aspx page? I've a custom query page and need to store the search criteria specified in an
XML file on the user machine from my web page (aspx). I form the XML at run time from the search fileds specfied by the user and now my aspx page should save it on client machine so that the user can open the same query on next
visit of the page.

And help is appreciated.

Nikhil

Nov 18 '05 #2
Thanks for replying. I'll not be uploading anything back to server on next
visit, I'll just read the file, extract the XML and then use the xml to form
my query.

But my question remain unanswered - How do I save the text that I form at
runtime into a file on the client machine? Currently I use this:

xmlDoc = Session["XmlDocument"] as XmlDocument;
string fileName = "query.xml";
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" +
fileName);
Response.ContentType = "text/xml";
Response.Write(xmlDoc.OuterXml);
Response.Flush();

But this saves the XML as well as the source from the current aspx page. How
do I save just the XML and/or get rid of all other source from the file.

Nikhil

"Martin Dechev" <de******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi, Nikhil Tayal,

If the info is not that large you can save it as a cookie on the client.

If it is really large you can prompt the user to save it and on the next
visit to upload it. This is very bad design regarding the security though,
because the users can upload practically anything.

A standard solution is to keep this data in the server in the profile of the user (supposing that you keep the profiles of your users and they (may)
authenticate before the visit to the page).

Greetings
Martin
"Nikhil Tayal" <a-******@microsoft.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Is there a way to write a file on the client machine from an aspx page?

I've
a custom query page and need to store the search criteria specified in an XML file on the user machine from my web page (aspx). I form the XML at

run
time from the search fileds specfied by the user and now my aspx page

should
save it on client machine so that the user can open the same query on next visit of the page.

And help is appreciated.

Nikhil


Nov 18 '05 #3
> But my question remain unanswered - How do I save the text that I form at
runtime into a file on the client machine?
I may be wrong, but your next question will be how to read the file on the
client machine from the aspx page. That's why I explained you how this
situation is usually handled.
xmlDoc = Session["XmlDocument"] as XmlDocument;
string fileName = "query.xml";
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" +
fileName);
Response.ContentType = "text/xml";
Response.Write(xmlDoc.OuterXml);
Response.Flush();

But this saves the XML as well as the source from the current aspx page. How do I save just the XML and/or get rid of all other source from the file.


Just like you do it, only call Response.End() instead of Response.Flush()

Greetings
Martin
Nov 18 '05 #4
You'd be MUCH better off using either Cookies, or even better XML UserData
persistence on the client.

See the topic here:
http://msdn.microsoft.com/library/de...am03052001.asp

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Nikhil Tayal" <a-******@microsoft.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Is there a way to write a file on the client machine from an aspx page? I've a custom query page and need to store the search criteria specified in an
XML file on the user machine from my web page (aspx). I form the XML at run time from the search fileds specfied by the user and now my aspx page should save it on client machine so that the user can open the same query on next
visit of the page.

And help is appreciated.

Nikhil

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mr Gordonz | last post: by
4 posts views Thread by Matt | last post: by
12 posts views Thread by =?Utf-8?B?RnJlZU5FYXN5?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.