Does anyone know of a base class that can be used to serve up an arbitrary file (potentially dynamically generated and temporary) from ASP.NET?
The kind of interface I’m thinking of would very simple and look something like this:
class FilePage : Control // I think...
{
protected Filename { get; set; } // the filename to dump out
protected bool Delete { get; set; } // Delete the (temporary) file when done?
protected string ContentType { get; Set; } // MIME type of the file
abstract protected void BindData();
}
you would derive from it and, in the abstract method, create whatever file you need to, set the properties and let the base class handle the rest.
My current use case is that I want to export data as an SQLite database.
edit:
- Superfiualy related to this question except that I must generate a temporary file.
You can create a “page” as a class that implements
IHttpHandler.Then you could subclass as you said to add all the functionality you wanted. You could also add some events in there if you wanted to push handling things like that ‘Delete’ property.
Lastly, you would need to update the web.config to listen to the proper URLs. In the
<httpHandlers>section add: