You are developing an ASP.NET MVC web application that enables users to open Microsoft
Excel files. The current implementation of the ExcelResult class is as follows.
You need to enable users to open Excel files. How should you implement the ExecuteResult
method? (To answer, select the appropriate options in the answer area.)
public override void ExecuteResult(ControllerContext context)
{
var response = context.HttpContext.Response;
var request = context.HttpContext.Request;
var canProcess = request.AcceptTypes.Contains(“application/vnd.ms-excel”);
if (canProcess)
{
response.Clear();
response.AddHeader(“content-disposition”, “attachment;filename=dl.xlsx”);
response.ContentType = “application/vnd.ms-excel”;
response.WriteFile(context.HttpContext.Server.MapPath(Path));
}
}