views:

17

answers:

1

I am not sure if this is possible... Right now I create various .RDP files that my users download directly off the server, with code such as this:

        System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.ContentType = "Content-Type=application/x-rdp rdp;charset=ISO-8859-1";
        Response.AddHeader("Content-Length", fileInfo.Length.ToString());
        Response.WriteFile(fileInfo.FullName);
        Response.End();

So a user would click a link and get a file link '~/Download/RemoteServer1234.RDP'.

I don't want these files on my server for various reasons (maintenance and security come to mind). Is there a way to make 'fake files' and give a pointer to the client to just download data that resides in memory? If so, then how does the server ultimately know when to remove any assigned memory?

A: 

Just use Response.Write() with a StringBuilder (via its ToString() method) containing the RDP file contents (which is an extremely simple format). Of course you can pass an arbitrary string as the filename in the Content-disposition header.

Here's a description of the RDP format (which you apparently already write to a file): Remote Desktop File Format

bowenl2