差分

ナビゲーションに移動 検索に移動

FileContentResult クラス (System.Web.Mvc)

486 バイト追加, 2012年3月30日 (金) 06:17
編集の要約なし
FileContentResultクラスとは、[[ASP.NET MVC]]の[[アクション・メソッド]]の戻り値([[ActionResult]]およびその派生クラス)として、byte配列の内容をバイナリデータとしてそのまま送信する[[FileResultクラス]]を継承したクラスである。
 
== 使用例 ==
<source lang="csharp">
using System.Web.Mvc;
using System.Text;
 
public class HomeController : Controller
{
public ActionResult DownloadCsv()
{
this.HttpContext.Response.AddHeader(
"Content-Disposition",
"attachment; filename=hello.csv");
 
byte[] data = Encoding.UTF8.GetBytes("hello, world");
return new FileContentResult(data, "text/csv");
}
}
</source>
== 関連項目 ==
匿名利用者

案内メニュー