Is it possible to return a string from controller upon a form s开发者_运维问答ubmission ?
[HttpPost]
public ActionResult Index()
{
return Content("some string", "text/plain");
}
You can, as Darin suggest, return Content(string); There are also other possibilities such as
[HttpPost]
public ActionResult Index(FormCollection form) {
/*
return Json(json);
return View;
return PartialView;
*/
}
If you return something other than an action result it will automatically be wrapped in a ContentResult.
[HttpPost]
public ContentResult Index(FormCollection form) {
/*
return Content(string);
return File(bytes, contentType);
return DateTime.Now;
return 2;
*/
}
public ActionResult Index()
{
// ...
return File(bytes, contentType);
}
精彩评论