Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 583
  • Last Modified:

ASP.NET writing to XML on client

Hello,

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?
0
AdamBock
Asked:
AdamBock
  • 3
  • 3
2 Solutions
 
Ajay SharmaCommented:
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 asp.net


References:

http://forums.asp.net/t/658848.aspx/1?sending+XML+file+to+server+to+save+from+client+side+javascript

http://stackoverflow.com/questions/638791/how-to-send-a-big-xml-to-client-in-asp-net-effectively
0
 
AdamBockAuthor Commented:
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)
0
 
Ajay SharmaCommented:
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
AdamBockAuthor Commented:
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?
0
 
Carl TawnSystems and Integration DeveloperCommented:
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.
0
 
AdamBockAuthor Commented:
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now