<

Question 37


70-486 Skills Measured >> 3.3 Design and implement MVC controllers and actions >>

Question

Selection List

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.

public class ExcelResult:ActionResult
{
public string path {get;set;}
public override ExecuteResult(ControllerContext context)
{
...
}
}
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.)

var response = context.HttpContext.Response;
var request = context.HttpContext.Request;
if (canProcess)
{
response.Clear();


response.WriteFile(context.HttpContext.Server.MapPath(Path));
}

Answer:

var response = context.HttpContext.Response;
var request = context.HttpContext.Request;

if (canProcess)
{
response.Clear();


response.WriteFile(context.HttpContext.Server.MapPath(Path));
}