Save a file on client

Discussion in 'ASP .Net' started by Nikhil Tayal, Feb 27, 2004.

  1. Nikhil Tayal

    Nikhil Tayal Guest

    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
     
    Nikhil Tayal, Feb 27, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:uXVBcMW$...
    > 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
    >
    >
     
    Martin Dechev, Feb 27, 2004
    #2
    1. Advertising

  3. Nikhil Tayal

    Nikhil Tayal Guest

    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" <> wrote in message
    news:%231MiEbW$...
    > 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" <> wrote in message
    > news:uXVBcMW$...
    > > 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
    > >
    > >

    >
    >
     
    Nikhil Tayal, Feb 27, 2004
    #3
  4. > 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
     
    Martin Dechev, Feb 27, 2004
    #4
  5. 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/default.asp?url=/library/en-us/dnwebteam/html/webteam03052001.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" <> wrote in message
    news:uXVBcMW$...
    > 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
    >
    >
     
    Eric Lawrence [MSFT], Feb 27, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. user
    Replies:
    1
    Views:
    767
    Bruce Barker
    Apr 4, 2005
  2. teo
    Replies:
    1
    Views:
    467
  3. BusyBoy
    Replies:
    2
    Views:
    605
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 31, 2006
  4. subhadip
    Replies:
    0
    Views:
    639
    subhadip
    Mar 28, 2007
  5. Shahar Golan
    Replies:
    5
    Views:
    292
    kaeli
    Oct 16, 2003
Loading...

Share This Page