Search code examples
c#windowswindows-runtimewindows-store-appsc++-cx

C++/CX HTTP Web Server for Windows Store App


I need to run an HTTP web server in a Windows Store app written in C++/CX and XAML. I'm implementing a WinRT version of Readium (an ePub reader, here's a link to the MFC version for reference). The MFC version uses Microsoft's Sample HTTP Server but this is incompatible with WinRT sadly.

Googling reveals no embeddable HTTP servers for C++/CX so I'll ask directly: does anyone know of an HTTP server written in C++/CX?

If there is no server written in C++/CX is there one written in another WinRT language (C# for instance) that can interop with C++/CX?


Solution

  • I was never able to find an HTTP server that would run inside a WinRT app though I believe it is technically possible. However, it turns out I didn't need a full HTTP server as the Windows WebView has a method called NavigateToLocalStreamUri that allows me to manually handle requests for files in the WebView (e.g., images, stylesheets) and return them to the WebView similar to how an HTTP server would.

    MSDN provides a simple example that resolves an image an HTML page in a WebView.