Click here to Skip to main content
13,863,642 members
Click here to Skip to main content
Add your own
alternative version


8 bookmarked
Posted 7 Nov 2013
Licenced CPOL

How to Host a KeePass Database in IIS 7.5

, 7 Nov 2013
Rate this:
Please Sign up or sign in to vote.
Create an ASP.NET HTTP handler and configure IIS 7.5 to load and save KeePass databases


KeePass is an open source password manager. The passwords are stored in a database with the .kdbx extension. The database can be on your local file system or on a web server.

If you put the database on an IIS webserver, you can access it from KeePass, but if you try to save, you get a 404 error. This is because the StaticFile HTTP handler in IIS only supports the GET method and KeePass requires PUT, MOVE and DELETE, in addition to GET. To add support for this, a custom HTTP handler has to be added to the webserver.

I have tested the solution in IIS 7.5, but it will probably work in IIS 7 as well.

Using the Code

The HTTP handler is a C# library project with a class that implements IHttpHandler. A reference to System.Web needs to be added.

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

public class UploadHandler : IHttpHandler
    public void ProcessRequest(HttpContext context)
        string path = Path.Combine(context.Request.PhysicalApplicationPath, 
        if (context.Request.RequestType == "DELETE")
        else if (context.Request.RequestType == "MOVE")
            string destination = Path.Combine(context.Request.PhysicalApplicationPath,
                                 .Split(new char[] { '/' }).Last());
            File.Move(path, destination);
        else if (context.Request.RequestType == "PUT")
            byte[] fileBytes;
            using (var reader = new BinaryReader(context.Request.InputStream))
                fileBytes = reader.ReadBytes((int)context.Request.InputStream.Length);
            File.WriteAllBytes(path, fileBytes);

    public bool IsReusable
        get { return false; }

To add the handler, put the following in web.config:

      <mimeMap mimeType="application/octet-stream" fileExtension=".kdbx" />
      <add name="UploadHandler_tmp" requireAccess="Read" 

           resourceType="Unspecified" type="UploadHandler" 

           verb="PUT,DELETE,MOVE" path="*.tmp" />
      <add name="UploadHandler_kdbx" requireAccess="Read" 

           resourceType="Unspecified" type="UploadHandler" 

           verb="DELETE" path="*.kdbx" />

Put the library DLL in a folder named "bin" on the web site.

File system

Now, you should be able to save your KeePass database!


  • First version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Johan L.
Software Developer Infracontrol
Sweden Sweden
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralCouple issues for noobs like me (But this article is good! Thanks!) Pin
Tomas Ramirez30-Apr-15 22:22
memberTomas Ramirez30-Apr-15 22:22 
GeneralMy vote of 5 Pin
David Pierson27-Jun-14 23:20
memberDavid Pierson27-Jun-14 23:20 
Generalpromising Pin
binabic8-Nov-13 4:24
memberbinabic8-Nov-13 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 8 Nov 2013
Article Copyright 2013 by Johan L.
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid