views:

525

answers:

2

I've written an HttpHandler that works fine when I test it on the ASP.NET development server.

In my Web.Config I have:

<add verb="*" path="Files.zip" type="MyNamespace.Zip, App_Code" />

And in my Handler in my App_Code folder I have the code below. Unfortunately, since the ASP.NET development server dumps everthing in the root -- http://localhost:1234/Files.zip works just fine. However, I'm trying to deploy to an intranet server where the the URL is something like http://myProjects/project. When I point my browser to http://myProjects/project/Files.zip I get a 404. How can I tweak the web config to get the right path? Or is the solution somewhere else? I've already tried prefixing the path with "~/" and "./".

(Namespace MyNamespace, file Zip.cs)
public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "application/octet-stream";
    DirectoryInfo di = new DirectoryInfo(context.Server.MapPath("files"));
    FileInfo[] fileinf = di.GetFiles();
    ZipFile zip = new ZipFile();
    foreach(FileInfo fi in fileinf)
    {
        zip.AddFile(fi.FullName, "");
    }
    zip.Save(context.Response.OutputStream);
}
+1  A: 

Did you try

path="/project/Files.zip"
Spencer Ruport
+2  A: 

Do you have the mappings set up in IIS on your intranet server such that the requests to *.zip are processed by the ASP.NET runtime? If not, the the request to files.zip will never get to your handler.

If you're on IIS 6 this link will help you set up the mapping of the aspnet_isapi.dll to zip extensions.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/4c840252-fab7-427e-a197-7facb6649106.mspx?mfr=true

thinkzig
I've tried all possible paths, so it seems this is probably the issue. Unfortunately I don't have privileges, so it will be hard to test or modify.
Chet
If you're heart is not set on the path ending in .zip you can just change it to be FilesZip.aspx or something similar. Good luck!
thinkzig