Is it possible to return anything else from the controller other than the view?
3 answers
You can, as Darin suggests, return Content (string); There are other possibilities such as
[HttpPost]
public ActionResult Index(FormCollection form) {
/*
return Json(json);
return View;
return PartialView;
*/
}
If you return anything other than the result of the action, it will be automatically completed in the ContentResult.
[HttpPost]
public ContentResult Index(FormCollection form) {
/*
return Content(string);
return File(bytes, contentType);
return DateTime.Now;
return 2;
*/
}
+3
a source to share