Tag / xml

This is just a short howto as I think it might come handy, as I struggled a bit on some points.

I needed a simple way to self-host a REST-like service (returning XML data) with fine control on the structure of the results.
I had a look at Nancy and others but finally choose to use Microsofts WebApi as it’s fine for what I am trying to do.

preparing the solution

First thing to do is grab the nuget-package Microsoft.AspNet.WebApi.SelfHost.
In addition I needed references to System.Xml as I want to use XmlDocument.

helper class for XML content

I want the replies to have content typetext/xml (instead of application/xml) and the only way I found is to use a helper class:

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

disable

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.