有一个动作:/ Home/GetName,并返回一个字符串"Mike",控制器和动作如:
public class HomeController : Controller
{
public string GetName()
{
return "Mike";
}
}
Run Code Online (Sandbox Code Playgroud)
如何在视图中显示此操作结果?(没有ajax更好)
Rah*_*thi 10
您可以使用ContentResult返回字符串之类的
public ActionResult GetName() {
return Content("Mike");
}
Run Code Online (Sandbox Code Playgroud)
请注意,默认情况下会返回text/plain类型ContentResult.