Moving action result into its own file

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-07-06 19:00:49 -07:00
parent 387b20b7ad
commit 882b1f6df5
3 changed files with 24 additions and 21 deletions

View File

@@ -75,6 +75,7 @@
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Models\ModuleFeature.cs" />
<Compile Include="Packaging\Commands\PackagingCommands.cs" />
<Compile Include="Packaging\Controllers\DownloadStreamResult.cs" />
<Compile Include="Packaging\Controllers\PackagingController.cs" />
<Compile Include="Packaging\Services\PackageExpander.cs" />
<Compile Include="Packaging\Services\PackageBuilder.cs" />

View File

@@ -1 +1,23 @@

using System.IO;
using System.Web.Mvc;
namespace Orchard.Modules.Packaging.Controllers {
public class DownloadStreamResult : ActionResult {
public string FileName { get; set; }
public string ContentType { get; set; }
public Stream Stream { get; set; }
public DownloadStreamResult(string fileName, string contentType, Stream stream) {
FileName = fileName;
ContentType = contentType;
Stream = stream;
}
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.ContentType = ContentType;
context.HttpContext.Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "\"");
Stream.Seek(0, SeekOrigin.Begin);
Stream.CopyTo(context.HttpContext.Response.OutputStream);
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using Orchard.Environment.Extensions;
@@ -104,23 +103,4 @@ namespace Orchard.Modules.Packaging.Controllers {
return RedirectToAction("Modules");
}
}
public class DownloadStreamResult : ActionResult {
public string FileName { get; set; }
public string ContentType { get; set; }
public Stream Stream { get; set; }
public DownloadStreamResult(string fileName, string contentType, Stream stream) {
FileName = fileName;
ContentType = contentType;
Stream = stream;
}
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.ContentType = ContentType;
context.HttpContext.Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "\"");
Stream.Seek(0, SeekOrigin.Begin);
Stream.CopyTo(context.HttpContext.Response.OutputStream);
}
}
}