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