-
Encapsulates the result of an action method and is used to perform a framework-level operation on behalf of the action method.
public ActionResult Index()
{
return Show();
}
public ActionResult Show()
{
return View();
}
-
Represents a user-defined content type that is the result of an action method.
public ActionResult Index()
{
return Content("Represents a user-defined content type that is the result of an action method.", "text/plain", System.Text.Encoding.UTF8);
}
-
Represents a result that does nothing, such as a controller action method that returns nothing.
public ActionResult Index()
{
return new EmptyResult();
}
-
Sends the contents of a binary file to the response.
public ActionResult Index()
{
//return new FileContentResult(Buffer, "application/pdf");
return File(Buffer, "application/pdf");
}
-
Sends the contents of a file to the response.
public ActionResult Index()
{
return File(Server.MapPath("~/doc/sample.pdf"), "application/pdf");
}
-
Sends binary content to the response by using a Stream instance.
public ActionResult Index()
{
using (var ms = new System.IO.MemoryStream())
{
TempImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
//return new FileStreamResult(ms, "image/png") { FileDownloadName = "logo.png" };
return File(ms, "image/png", "logo.png");
}
}
-
Defines an object that is used to indicate that the requested resource was not found.
public ActionResult Index()
{
return HttpNotFound("Page not fould");
}
-
Provides a way to return an action result with a specific HTTP response status code and description.
public ActionResult Index()
{
return new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized);
}
-
Represents the result of an unauthorized HTTP request.
public ActionResult Index()
{
return new HttpUnauthorizedResult("Please sign in");
}
-
Sends JavaScript content to the response.
public ActionResult Index()
{
return JavaScript("alert(new Date());");
}
-
Represents a class that is used to send JSON-formatted content to the response.
public ActionResult Index()
{
return Json(new { Message = "Represents a class that is used to send JSON-formatted content to the response." });
}
-
Represents a base class that is used to send a partial view to the response.
public ActionResult Index()
{
return PartialView();
}
-
Controls the processing of application actions by redirecting to a specified URI.
public ActionResult Index()
{
//return Redirect("/Product"); // 302
return RedirectPermanent("/Product"); // 301
}
Redirect and RedirectPermanent
-
Represents a result that performs a redirection by using the specified route values dictionary.
public ActionResult Index()
{
//return RedirectToAction("Show");
//return RedirectToActionPermanent("Show");
//return RedirectToRoute(new { action = "Show" });
return RedirectToRoute(new { action = "Show" });
}
-
Represents a class that is used to render a view by using an IView instance that is returned by an IViewEngine object.
public ActionResult Index()
{
return View();
}