Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On every ServiceStack <a href="http://mono.servicestack.net/json/metadata?op=Hello" rel="nofollow noreferrer">/metadata page</a> lists the different ways a client can request a specific Content-Type:</p> <blockquote> <p>To override the Content-type in your clients HTTP <strong>Accept</strong> Header, append <strong>?format=xml</strong> or add .<strong>format</strong> extension</p> </blockquote> <p>E.g. The client can specify your custom ContentType with <strong>?format=x-my-content-type</strong>, adding <code>.x-my-content-type</code> extension or by specifying the HTTP Header (in the HttpClient): </p> <blockquote> <p>Accept: application/x-my-content-type</p> </blockquote> <p>Otherwise if your HttpClient doesn't send an Accept header you can specify the default content type in your AppHost with:</p> <pre><code>SetConfig(new HostConfig { DefaultContentType = "application/x-my-content-type" }); </code></pre> <p><em>Note: All Configuration options in ServiceStack are set on <code>HostConfig</code>.</em></p> <p>The issue when calling web services from a web browser is that they typically ask for <code>Accept: text/html</code> which by contract ServiceStack obliges by returning back HTML if it is enabled.</p> <p>To ensure your Content-Type is always returned you may also want to disable the HTML feature with:</p> <pre><code>SetConfig(new HostConfig { EnableFeatures = Feature.All.Remove(Feature.Html), }); </code></pre> <p>Otherwise if you want to <strong>override the Accept</strong> header you can force your service to always return your Content-Type by decorating your Response DTO inside a HttpResult, i.e:</p> <pre><code>return new HttpResult(dto, "application/x-my-content-type"); </code></pre> <p>Otherwise anywhere outside of your Service (e.g. Request/Response filter) you can set the Response ContentType anywhere that has access to a <code>IHttpRequest</code> with:</p> <pre><code>httpReq.ResponseContentType = "application/x-my-content-type"; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload