404 response appended to webapi response
<p>I have managed to get TWO responses for a single web request:</p>

<ol>
<li>My webapi response ( a simple string with 200 status code)</li>
<li>a 404, from what looks like a static file handler</li>
</ol>

<p>Screenshot from chrome:</p>

<p><a href="https://i.stack.imgur.com/CvCvD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CvCvD.png" alt="Screen shot"></a></p>

<p>My setup is:</p>

<ul>
<li>F#</li>
<li>Mono on Ubuntu 15.10</li>
<li>xsp4 as the web server</li>
<li>Owin as the routing engine</li>
</ul>

<p>As you can see from the screenshot the correct response is printed (sometimes - sigh) on the first line of the browser's reponse, and then immediately followed on the page by the standard 404 page.</p>

<p>Startup code:</p>

<pre><code>type Startup() =

  static member RegisterWebApi(config: HttpConfiguration) =
    // Configure routing
    config.MapHttpAttributeRoutes()
    // Configure serialization
    config.Formatters.XmlFormatter.UseXmlSerializer &lt;- true
    config.Formatters.JsonFormatter.SerializerSettings.ContractResolver &lt;- Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()

  member __.Configuration(builder: IAppBuilder) =
    let config = new HttpConfiguration()
    Startup.RegisterWebApi(config)
    builder.UseWebApi(config) |&gt; ignore
    builder.UseErrorPage() |&gt; ignore
</code></pre>

<p>Controller code:</p>

<pre><code>[&lt;RoutePrefix("api")&gt;]
type WordsearchController() =
  inherit ApiController()

  [&lt;Route("")&gt;]
  member this.Get() =
    this.Request.CreateResponse&lt;string&gt;(HttpStatusCode.OK, "This is my simple output")
</code></pre>

<p>I have tried removing the static file handler in the web.config, using MVC style route mapping in startup, and various routing attributes for the controller.  </p>

<p>It just seems like both the webapi routing and the static file handler are BOTH putting their two cents into the reponse, instead of one overriding the other.</p>

<p>As per request from @mark, the request is a simple GET to <a href="http://localhost:9000/api" rel="nofollow noreferrer">http://localhost:9000/api</a>, and the response is:</p>

<p>HEADER</p>

<pre><code>HTTP/1.0 404 Not Found
Date: Mon, 18 Jan 2016 00:11:17 GMT
Server: Mono.WebServer.XSP/4.2.0.0 Linux
X-AspNet-Version: 4.0.30319
Content-Length: 5085
Cache-Control: private
Content-Type: text/html
Keep-Alive: timeout=15, max=94
Connection: Keep-Alive
</code></pre>

<p>BODY</p>

<pre><code>GET api

404 Not Found

localhost:9000

5.0 KB

127.0.0.1:9000


2ms
HeadersResponseHTMLCache

&lt;string&gt;This is my simple output&lt;/string&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional
.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;style type="text/css"&gt;
body { background-color: #FFFFFF; font-size: .75em; font-family: Verdana, Helvetica, Sans-Serif; margin
: 0; padding: 0;    color: #696969; }
a:link { color: #000000; text-decoration: underline; }
a:visited { color: #000000; }
a:hover { color: #000000; text-decoration: none; }
a:active { color: #12eb87; }
p, ul { margin-bottom: 20px; line-height: 1.6em; }
pre { font-size: 1.2em; margin-left: 20px; margin-top: 0px; }
h1, h2, h3, h4, h5, h6 { font-size: 1.6em; color: #000; font-family: Arial, Helvetica, sans-serif; }

h1 { font-weight: bold; margin-bottom: 0; margin-top: 0; padding-bottom: 0; }
h2 { font-size: 1em; padding: 0 0 0px 0; color: #696969; font-weight: normal; margin-top: 0; margin-bottom
: 20px; }
h2.exceptionMessage { white-space: pre; }
h3 { font-size: 1.2em; }
h4 { font-size: 1.1em; }
h5, h6 { font-size: 1em; }
#header { position: relative; margin-bottom: 0px; color: #000; padding: 0; background-color: #5c87b2
; height: 38px; padding-left: 10px; }
#header h1 { font-weight: bold; padding: 5px 0; margin: 0; color: #fff; border: none; line-height: 2em
;   font-family: Arial, Helvetica, sans-serif; font-size: 32px !important; }
#header-image { float: left; padding: 3px; margin-left: 1px; margin-right: 1px; }
#header-text { color: #fff; font-size: 1.4em; line-height: 38px; font-weight: bold; }
#main { padding: 20px 20px 15px 20px; background-color: #fff; _height: 1px; }
#footer { color: #999; padding: 5px 0; text-align: left; line-height: normal; margin: 20px 0px 0px 0px
;   font-size: .9em; border-top: solid 1px #5C87B2; }
#footer-powered-by { float: right; }
.details { font-family: monospace; border: solid 1px #e8eef4; white-space: pre; font-size: 1.2em; overflow
: auto; padding: 6px; margin-top: 6px; background-color: #eeeeff; color: 555555 }
.details-wrapped { white-space: normal }
.details-header { margin-top: 1.5em }
.details-header a { font-weight: bold; text-decoration: none }
p { margin-bottom: 0.3em; margin-top: 0.1em }
.sourceErrorLine { color: #770000; font-weight: bold; }
&lt;/style&gt;
&lt;script type="text/javascript"&gt;
    var hideElementsById = new Array ();
    window.onload = function () {
        if (!hideElementsById || hideElementsById.length &lt; 1)
            return;
        for (index in hideElementsById)
            toggle (hideElementsById [index]);
    }

    function toggle (divId)
    {
        var e = document.getElementById (divId);
        if (!e)
            return;
        var h = document.getElementById (divId + "Hint");
        if (e.style.display == "block" || e.style.display == "") {
            e.style.display = "none";
            if (h)
                h.innerHTML = " (click to show)";
        } else {
            e.style.display = "block";
            if (h)
                h.innerHTML = " (click to hide)";
        }
    }
&lt;/script&gt;
&lt;title&gt;Error 404&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="page"&gt;
&lt;div id="header"&gt;
&lt;div id="header-text"&gt;Application Exception&lt;/div&gt;
&lt;/div&gt;
&lt;div id="main"&gt;
  &lt;h1&gt;System.Web.HttpException&lt;/h1&gt;
  &lt;h2 class="exceptionMessage"&gt;The resource cannot be found.&lt;/h2&gt;
  &lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt; HTTP 404.The resource you are looking for (or one of its dependencies
) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following
 URL and make sure that it is spelled correctly.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt; Requested URL: /api
&lt;/p&gt;
&lt;div&gt;&lt;strong&gt;Exception stack trace:&lt;/strong&gt;&lt;/div&gt;
&lt;div class="details"&gt;  at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context
) &amp;lt;0x403b0a40 + 0x00733&amp;gt; in &amp;lt;filename unknown&amp;gt;:0 
  at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback
 callback, System.Object state) &amp;lt;0x403b0240 + 0x00153&amp;gt; in &amp;lt;filename unknown&amp;gt;:0 
  at System.Web.HttpApplication+&amp;lt;Pipeline&amp;gt;c__Iterator1.MoveNext () &amp;lt;0x40332110 + 0x04416&amp;gt
; in &amp;lt;filename unknown&amp;gt;:0 
  at System.Web.HttpApplication.Tick () &amp;lt;0x40330c60 + 0x00057&amp;gt; in &amp;lt;filename unknown&amp;gt;:0 &lt;
/div&gt;&lt;div id="footer"&gt;
  &lt;div style="color:Black;"&gt;&lt;strong&gt;Version Information:&lt;/strong&gt; &lt;tt&gt;4.2.1 (Stable 4.2.1.102/6dd2d0d
 Thu Nov 12 09:52:44 UTC 2015)&lt;/tt&gt;; ASP.NET Version: &lt;tt&gt;4.0.30319.17020&lt;/tt&gt;&lt;/div&gt;
  &lt;div id="footer-powered-by"&gt;Powered by &lt;a href="http://mono-project.com/"&gt;Mono&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;!--
[System.Web.HttpException]: Path &amp;#39;/api&amp;#39; was not found.
  at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context) &lt;0x403b0a40 + 0x00733
&gt; in &lt;filename unknown&gt;:0 
  at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback
 callback, System.Object state) &lt;0x403b0240 + 0x00153&gt; in &lt;filename unknown&gt;:0 
  at System.Web.HttpApplication+&lt;Pipeline&gt;c__Iterator1.MoveNext () &lt;0x40332110 + 0x04416&gt; in &lt;filename
 unknown&gt;:0 
  at System.Web.HttpApplication.Tick () &lt;0x40330c60 + 0x00057&gt; in &lt;filename unknown&gt;:0 
--&gt;


1 request

5.0 KB

2ms (onload: 88ms)
</code></pre>