mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Moving action result into its own file
--HG-- branch : dev
This commit is contained in:
@@ -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" />
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user