首页 > 技术文章 > 动作方法

zhuxiang1633 2017-11-04 11:37 原文

1.View方法

public ActionResult Index()
{
    //完整路径
    return View("~/Areas/Admin/Views/Home/Index.cshtml");
}

 

ActionResult解析:(抽象类)视图结果
子类:

System.Web.Mvc.ContentResult:ContentResult Controller.Content("") 向用户输出字符串,没有多余的文本
System.Web.Mvc.EmptyResult: 返回空内容,Controller没有提供方法
System.Web.Mvc.FileResult(抽象): 返回一个文件,用于验证码
FileContentResult(子类): Controller.File(new byte[],""); e.g return new FileContentResult(new byte[1024],"image/jpeg");
FilePathResult(子类): Controller.File("",""); e.g return new FilePathResult("logo.jpg","image/jpeg");
FileStreamResult(子类):e.g return new FileStreamResult(new FileStream("logo.jpg",FileMode.Open),"image/jpeg")
System.Web.Mvc.ViewResult:

 

推荐阅读