Q

How can I make IIS automatically save the XML file into a directory?

I'm a rookie when it comes to IIS (using 5.0) and XML. I'm getting an XML pushed to my IIS. How can I automate for IIS to save the XML file into a directory? Any help will be greatly appreciated.
It depends on how the file is being "pushed." IIS is not only about Web applications; it is also an FTP server. So the file could be pushed through FTP, which is really straightforward with regards to saving it to a folder.

On the other hand, if the receiver is an ASP.NET application, you can easily achieve the same effect by creating an IHttpHandler that receives incoming files and stores them in a know location. The handler code would be something like the following:

using System;
using System.IO;
using System.Web;

public class FileSaver : IHttpHandler
{
 public bool IsReusable
 {
  get { return true; }
 }

 public void ProcessRequest(HttpContext context)
 {
  context.Request.Files[0].SaveAs(@"c:incomingdata.xml");
 }
}

Then, you map this handler to a certain location in the Web.config file:

<configuration>
 <system.web>
        <httpHandlers>
            <add verb="POST" path="filesaver.ashx" type="FileSaver,
MyAssembly" />
        </httpHandlers>        
 </system.web>
</configuration>

Now you can POST a file to the filesaver.ashx URL and the handler will save it to the location specified.

This was last published in September 2003

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close