Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2><a href="https://github.com/ServiceStack/ServiceStack/wiki/Routing#reverse-routing" rel="nofollow">Reverse Routing</a></h2> <p>The <a href="https://github.com/ServiceStack/ServiceStack/wiki/Routing#reverse-routing" rel="nofollow">Reverse Routing</a> section in the wiki shows how to use extension methods on a popualated <strong>Request DTO</strong> to generate relative and absolute URI's:</p> <p>If you use <code>[Route]</code> metadata attributes (as opposed to the Fluent API) you will be able to generate strong-typed URI's using just the DTOs, letting you create urls outside of ServiceStack web framework as done with .NET Service Clients using the <code>ToUrl(HttpMethod)</code> and <code>ToAbsoluteUri(HttpMethod)</code>, e.g:</p> <pre><code>[Route("/reqstars/search", "GET")] [Route("/reqstars/aged/{Age}")] public class SearchReqstars : IReturn&lt;ReqstarsResponse&gt; { public int? Age { get; set; } } var relativeUrl = new SearchReqstars { Age = 20 }.ToGetUrl(); var absoluteUrl = new SearchReqstars { Age = 20 }.ToAbsoluteUri(); relativeUrl.Print(); //= /reqstars/aged/20 absoluteUrl.Print(); //= http://www.myhost.com/reqstars/aged/20 </code></pre> <p>The <strong>Email Contacts</strong> demo shows an example of using the above Reverse Routing extension methods to <a href="https://github.com/ServiceStackApps/EmailContacts#bootstrap-forms" rel="nofollow">populate routes for HTML Forms and Links in Razor Views</a>.</p> <h3>Other Reverse Routing Extension methods</h3> <pre><code>new RequestDto().ToPostUrl(); new RequestDto().ToPutUrl(); new RequestDto().ToDeleteUrl(); new RequestDto().ToOneWayUrl(); new RequestDto().ToReplyUrl(); </code></pre> <h2>Accessing Http Request</h2> <p>You can also inspect the incoming underlying httpRequest with:</p> <pre><code>var httpReq = base.RequestContext.Get&lt;IHttpRequest&gt;(); </code></pre> <p>As well as the underlying ASP.NET (or HttpListener) Request object with:</p> <pre><code>var aspNetReq = httpReq.OriginalRequest; </code></pre> <p>They should contain additional properties that should be more useful.</p>
    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.
 

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