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

  • SEARCH
  • Home
  • 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 8614603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:09:33+00:00 2026-06-12T05:09:33+00:00

Hi I wanted to know if anyone has modified the restfiles example in servicestack,

  • 0

Hi I wanted to know if anyone has modified the restfiles example in servicestack,
so that it can return unchanged xml files from the filesystem?

In other words, act as a webserver (IIS, cassini or apache etc.) but with REST mapping that comes with servicestack.

At the moment the response is preformated and i cant see how to change that.

  • 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-12T05:09:35+00:00Added an answer on June 12, 2026 at 5:09 am

    I just want to show my solution to my original question in case others are looking to modify the restfiles example´s behaviour. the mod allows you to return xml or other filetypes to the browser without changing the content of the file:

    public override object OnGet(Files request)
    {
        var targetFile = GetAndValidateExistingPath(request);
        var isDirectory = Directory.Exists(targetFile.FullName);
        var hasParameters = this.RequestContext.AbsoluteUri.ToString().Contains("?") ? true : false;
    
        if (!isDirectory && request.ForDownload)
            return new HttpResult(targetFile, asAttachment:true);
    
        if (string.IsNullOrEmpty(targetFile.Name) || hasParameters)
        {
            var response = isDirectory
                ? new FilesResponse { Directory = GetFolderResult(targetFile.FullName) }
                : new FilesResponse { File = GetFileResult(targetFile) };
            return response;
        }
        return new HttpResult(targetFile);
    }
    

    So basically if the incomming request is empty or has parameters then we return a filesresponse otherwise we return an HttpResult directly displaying the files content.
    I hope this is useful to somebody.

    Mythz: if there is something wrong in the code.. let us know. I tried to convert the example to .Net 4.0 but somewhere it breaks and the ajax file content viewing and listing part in /#!files doesnt show up. (perhaps i lost something in web.config during vs2010 conversion). Will you be releasing 4.0 compatible versions of the examples in the near future? … Thanks again for the great work

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

Sidebar

Related Questions

I wanted to know if anyone has had experience with trying to remove the
I wanted to know if anyone else has experienced this 'glitch' between browsers with
I wanted to know if anyone has worked out how to disable the Public
If anyone has ever wanted to know how to change the background color of
Just wanted to know if anyone is really using Objects and Collections in Oracle
I wanted to know if any one can explain the control flow of the
Wanted to know if there was a way one could query shelveset details from
I wanted to know that if I am doing correctly, regarding retain and release
Does anyone know how I can style dynamic elements created via the DOM method
I am creating a simple register form and I wanted to know if anyone

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.