ASP.NET writing to XML on client

Posted on 2011-03-14
Last Modified: 2013-12-17

Is it possible to write to an XML file stored on the client from an ASP.NET page?

I created an ASP.NET website in Visual Studio which creates a directory structure in C:\ProgramData then creates an XML document and writes to it. That worked really well but now that it's running on the server, it's creating the folder/files on the server :S

Basically what I want is for a user to click a button on a website which as a result will dynamically create an xml document which saves to the clients machine. How can I achieve this?
Question by:AdamBock
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 18

Accepted Solution

Ajay Sharma earned 500 total points
ID: 35135402
While on webserver the c:\..... paths are not accessible.
So what you need to do is to create a folder e.g. UserFiles on the server, this folder must be inside the root of application.
Then, generate the XML file and save it into UserFiles folder programatically, then use transmit file method to send the xml file to the client browser

Note: you can't access client mechine's file system using


Author Comment

ID: 35135435
Thanks for that. So the page generates the XML file on the server-side and saves it in the root of the application. That's easily done... Then all thats left is for the XML file to automatically be sent to the client using the transmit file method.. I had a look at those two references but I'm still a little unclear on how it can be done (technically)
LVL 18

Expert Comment

by:Ajay Sharma
ID: 35135468
You understood it right.

1) In the first step, a file needs to be exists on the server before sending
2) Send file to the client, this will show a save/open dialog on the user's browser screen.
For example when you download a zip file a browser save/open dialog comes.
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.


Author Comment

ID: 35135558
ahhh ok..
is there any way I can create a fully automated process where by only one click, an xml file can be generated and saved on the client side?
LVL 52

Expert Comment

by:Carl Tawn
ID: 35135653
You can't force the file onto the client machine. The best you can achieve is to create the file on the server and stream it to the browser. The result of that will be to prompt the user to save the file, and select a location to save to.

Technically the file doesn't have to physically exist on the server; you can create it in memory and stream it to the browser.
LVL 18

Assisted Solution

by:Ajay Sharma
Ajay Sharma earned 500 total points
ID: 35135697

Author Comment

ID: 35143057
thanks for your help.. this solves the problem I described in my original question however I'm going to start a new, more detailed question as I'm still unsure how to achieve what I want

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question