Reputation: 1977
I'm working on an ASP.NET MVC App that has buttons that have the server return an rdp file, which is created by my business layer.
What I want is to be able to have the server create this rdp file, then serve it, without having it stored on disk.
What would be the best way to go about this?
Thanks.
Upvotes: 5
Views: 2724
Reputation: 17824
You can create the file in a MemoryStream and then serve it by using Response.Write
Also don't forget to set the ContentType to "application/rdp"
Edit: As Danny Chen suggested you can use FileStreamResult
in the controller class
Stream stream = new MemoryStream();
//Fill the stream here
return new FileStreamResult(stream,"application/rdp")
Upvotes: 7
Reputation: 1691
I would use a MemoryStream object to write the data to a memory buffer.
But It all depends on your business layer, if it's fexible enough to output data to arbitrary streams.
Alternatively, if on Unix-like machine, mount a folder using ramfs and use that for temp storage, so the file is stored in memory. But I guess small chance you are using ASP.NET with Linux/BSD.
Upvotes: 1