public ActionResult Download(string name, string path) { var file = new BlobFile2(User.Identity.Name, path + name); if (file.Exists() && !file.IsDirectory()) { if (name != null) { Response.StatusCode = 200; Response.ContentType = file.ContentType(); Response.AppendHeader("Content-Disposition", "attachment; filename=" + name); file.GetBlob().DownloadToStream(Response.OutputStream); } else { DateTime dt; if (DateTime.TryParse(Request.Headers["If-Modified-Since"], out dt) && (file.LastModified() - DateTime.SpecifyKind(dt.ToUniversalTime(), DateTimeKind.Utc)).TotalSeconds < 1.0) { Response.StatusCode = 304; return new EmptyResult(); } Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(true); Response.Cache.SetMaxAge(TimeSpan.FromSeconds(300)); Response.Expires = 300; Response.ContentType = file.Properties().ContentType; file.GetBlob().DownloadToStream(Response.OutputStream); } } else { Response.StatusCode = 404; } return new EmptyResult(); }