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 first published in September 2003

Dig deeper on Win Development Resources

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.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close