views:

61

answers:

1

I have a custom IHttpHandler which is used by thick clients to download files using a url such as

http://url.ashx?id=123&version=456 

the code handler basically ends with

context.Response.WriteFile(myLocalServerPath);

Is it possible to replace this using the typical asp.net mvc controller pattern ?

+3  A: 

In an action:

byte[] fileBytes = ...;
string fileName = "example";
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

(Or a more specific MIME type if known)

Ian Henry