views:

104

answers:

1

I need to write an action that will return a FileResult from a string

+1  A: 

You can use the FileContentResult class.

        var contentType = "text/xml";
        var content = "<content>Your content</content>";
        var bytes = Encoding.UTF8.GetBytes(content);
        var result = new FileContentResult(bytes, contentType);
        result.FileDownloadName = "myfile.xml";
        return result;

Hope it helps,

/Klaus

klausbyskov