Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9292011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:46:45+00:00 2026-06-18T20:46:45+00:00

For example, if I have standard request and response DTOs, linked up via IReturn<T>

  • 0

For example, if I have standard request and response DTOs, linked up via IReturn<T>, what are the reasons to have a service method signature like the following, as seen in various online examples (such as this one, although not consistently throughout):

public object Get(DTO.MyRequest request)

rather than:

public IList<DTO.MyResponse> Get(DTO.MyRequest request)

Is an object return type here simply to support service features like gzip compression of the output stream, which results in the output being a byte array? It seems that one would want to have the appropriate stronger return type from these so-called “action” calls, unless I’m missing some common scenario or use case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:46:46+00:00Added an answer on June 18, 2026 at 8:46 pm

    It used to be a limitation that the New API only supported an object return type, but that hasn’t been the case for a while where all examples on the New API wiki page now use strong-typed responses.

    One of the reasons where you might want to return an object return type is if you want to decorate the response inside a HttpResult, e.g:

        public object Post(Movie movie)
        {
            var isNew = movie.Id == null;
            Db.Save(movie); //Inserts or Updates
    
            var movie = new MovieResponse {
                Movie = Db.Id<Movie>(newMovieId),
            };
            if (!isNew) return movie;
    
            //Decorate the response if it was created
            return new HttpResult(movie) {
                StatusCode = HttpStatusCode.Created,
                Headers = {
                  { HttpHeaders.Location, Request.AbsoluteUri.CombineWith(movieId) }
                }
            };
        }
    

    It’s also useful if you want to return different responses based on the request (though it’s not something I recommend), e.g:

        public object Get(FindMovies request)
        {
            if (request.Id != null)
                return Db.Id<Movie>(movie.Id);
    
            return Db.Select<Movie>();
        }
    

    If you do choose to return an object I highly recommend decorating your Request DTO with the IReturn<T> marker to give a hint to ServiceStack what the expected response of the service should be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to have my permalinks to standard format, something like http://example.com/?page_id=2 . Now
Example: I have a selector like this, which I give to another method as
I would like my API to have a validation-only request. For example, if I
Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I
I have a request to alter a standard Django login of email and password
If I for example have <p> some long text </p> on my HTML page,
Why does: const char example; (uint64*)example have a value of 140734799798420 and *(uint64*)example have
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example: I have an class that inherits from UIImageView. An object creates an instance
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.