1. ActionResult
ViewResult 返回响应的视图
ContentResult 返回字符串
public ActionResult Content(){return Content("Content");}
RedirectResult 重定向
RedirectToRouteResult 根据路由重定向
FileContentResult 文件内容
public ActionResult GetPhoto(string fileName){if (string.IsNullOrEmpty(fileName)){return Content(nameof(fileName) + "为空!");}return File("~/Uploads/" + fileName, "image/jpg");}public ActionResult UploadPhoto(){return View();}[HttpPost]public ActionResult UploadPhoto(HttpPostedFileBase file){string fileName = $"{DateTime.Now.Ticks}.{file.FileName.Split('.').Last()}";string savePath = "~/Uploads/" + fileName;file.SaveAs(Request.MapPath(savePath));return Content(fileName);}
JsonResult 返回Json数据
HttpStatusCodeResult 状态码
PartialViewResult 分部视图页面,类似于组件
Http.Action() Html.Partial()
